1. Go to this page and download the library: Download freespoke/partner 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/ */
freespoke / partner example snippets
use Freespoke\Partner\Article;
use Freespoke\Partner\Client;
use Freespoke\Partner\Person;
$apiKey = getenv('PARTNERS_API_TOKEN');
$client = Client::create($apiKey, 'https://api.partners.freespoke.com');
$article = new Article();
$article->url = 'https://example.com/article';
$article->title = 'Example Title';
$article->description = 'Short summary';
$article->content = '<p>Hello world</p>';
$article->keywords = ['news', 'example'];
$article->publish_time = new DateTimeImmutable('2024-01-01T00:00:00Z');
$article->image_url = 'https://example.com/image.jpg';
$author = new Person();
$author->id = 'author-1';
$author->name = 'John Doe';
$author->url = 'https://example.com/authors/john';
$author->twitter_id = 'john';
$author->facebook_id = 'john.fb';
$article->setAuthors($author);
$result = $client->index($article);
if ($result === null) {
// The API returned an error message or an incomplete response body.
exit(1);
}
$status = $client->getIndexStatus($result->job_id);
$epoch = $client->getEpoch();
use GuzzleHttp\Client as GuzzleClient;
use Freespoke\Partner\Client;
$http = new GuzzleClient([
'base_uri' => 'https://api.partners.freespoke.com/',
'timeout' => 10,
]);
$client = new Client($http, $apiKey);
use Freespoke\Partner\Client;
// Uses the default Freespoke token endpoint (https://accounts.freespoke.com/realms/freespoke/...).
$client = Client::createWithClientCredentials(
clientId: getenv('PARTNER_CLIENT_ID'),
clientSecret: getenv('PARTNER_CLIENT_SECRET'),
);
// Use exactly like an API-key client — token management is transparent.
$result = $client->index($article);
$result = $client->index($article);
$status = $client->getIndexStatus($jobId);
$epoch = $client->getEpoch();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.