1. Go to this page and download the library: Download knops/sendfox-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
knops / sendfox-client example snippets
use GuzzleHttp\Client;use GuzzleHttp\Psr7\HttpFactory;use Knops\SendfoxClient\SendfoxClient;
// Setup HTTP client en factories
$httpClient = new Client();
$httpFactory = new HttpFactory();
// Initialiseer Sendfox client
$sendfox = new SendfoxClient(
bearerToken: 'your-sendfox-api-token',
httpClient: $httpClient,
requestFactory: $httpFactory,
streamFactory: $httpFactory
);
// Gebruik de API
$campaigns = $sendfox->campaigns()->all();
$contacts = $sendfox->contacts()->all();
use Knops\SendfoxClient\SendfoxClient;use Nyholm\Psr7\Factory\Psr17Factory;use Symfony\Component\HttpClient\Psr18Client;
$httpClient = new Psr18Client();
$psr17Factory = new Psr17Factory();
$sendfox = new SendfoxClient(
bearerToken: 'your-sendfox-api-token',
httpClient: $httpClient,
requestFactory: $psr17Factory,
streamFactory: $psr17Factory
);
// Huidige gebruiker informatie
$user = $sendfox->user()->me();
// Contact velden van gebruiker
$contactFields = $sendfox->user()->contactFields();
use Knops\SendfoxClient\Models\Campaign;
use Knops\SendfoxClient\Models\Contact;
use Knops\SendfoxClient\Models\ContactList;
use Knops\SendfoxClient\Models\Form;
use Knops\SendfoxClient\Models\Automation;
use Knops\SendfoxClient\Models\User;
// Creëer model van array data
$campaign = Campaign::fromArray($campaignData);
$contact = Contact::fromArray($contactData);
$list = ContactList::fromArray($listData);
$form = Form::fromArray($formData);
$automation = Automation::fromArray($automationData);
$user = User::fromArray($userData);
// Converteer model terug naar array
$array = $campaign->toArray();
$contact = Contact::fromArray($contactData);
// Toegang tot alle contact eigenschappen
echo $contact->id; // Contact ID
echo $contact->email; // Email address
echo $contact->first_name; // Voornaam
echo $contact->last_name; // Achternaam
echo $contact->ip_address; // IP adres
echo $contact->unsubscribed_at; // Uitschrijf datum (null als niet uitgeschreven)
echo $contact->created_at; // Aanmaak datum
echo $contact->updated_at; // Update datum
// Controleer uitschrijf status
if ($contact->isUnsubscribed()) {
echo "Contact is uitgeschreven op: " . $contact->unsubscribed_at;
} else {
echo "Contact is actief";
}
// Symfony DI example
$container->register(SendfoxClient::class)
->setArguments([
'$bearerToken' => '%sendfox.api_token%',
'$httpClient' => new Reference(ClientInterface::class),
'$requestFactory' => new Reference(RequestFactoryInterface::class),
'$streamFactory' => new Reference(StreamFactoryInterface::class),
]);
use Psr\Http\Client\ClientInterface;
use PHPUnit\Framework\TestCase;
class SendfoxClientTest extends TestCase
{
public function testCampaignsCall()
{
$httpClient = $this->createMock(ClientInterface::class);
// Setup mock expectations...
$sendfox = new SendfoxClient(
'test-token',
$httpClient,
$requestFactory,
$streamFactory
);
// Test your logic...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.