1. Go to this page and download the library: Download leadpingai/sdk 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/ */
leadpingai / sdk example snippets
use Http\Promise\FulfilledPromise;
use Http\Promise\Promise;
use Leadping\OpenApiClient\LeadpingOpenApiClient;
use Microsoft\Kiota\Abstractions\Authentication\AuthenticationProvider;
use Microsoft\Kiota\Abstractions\RequestInformation;
use Microsoft\Kiota\Http\GuzzleRequestAdapter;
final class LeadpingAuthenticationProvider implements AuthenticationProvider
{
public function __construct(private readonly string $credential)
{
}
public function authenticateRequest(
RequestInformation $request,
array $additionalAuthenticationContext = []
): Promise {
$request->getHeaders()->tryAdd('Authorization', 'Bearer ' . $this->credential);
return new FulfilledPromise($request);
}
}
$credential = getenv('LEADPING_API_KEY');
if ($credential === false || $credential === '') {
throw new RuntimeException('LEADPING_API_KEY is not set.');
}
$adapter = new GuzzleRequestAdapter(
new LeadpingAuthenticationProvider($credential)
);
$client = new LeadpingOpenApiClient($adapter);
$lead = $client->leads()->byId('lead-id')->get()->wait();
echo $lead->getId();
// Requires a user access token.
$currentUser = $client->users()->me()->get()->wait();
// Retrieve organization resources by ID.
$source = $client->sources()->byId('source-id')->get()->wait();
$lead = $client->leads()->byId('lead-id')->get()->wait();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.