1. Go to this page and download the library: Download eventfarm/marketo-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/ */
eventfarm / marketo-client example snippets
namespace App;
use EventFarm\Marketo\Oauth\AccessToken;
use EventFarm\Marketo\MarketoClient;
use EventFarm\Marketo\TokenRefreshInterface;
class DemoMarketoClient implements TokenRefreshInterface
{
public function getMarketoClient():MarketoClient
{
if (empty($this->marketo)) {
$this->marketo = MarketoClient::withDefaults(
'ACCESS_TOKEN',
'TOKEN_EXPIRES_IN', // when the current access token expires (in seconds)
'TOKEN_LAST_REFRESH', // when the current access token was last refreshed (as a UNIX timestamp)
'CLIENT_ID',
'CLIENT_SECRET',
'BASE_URL',
$this // TokenRefreshInterface
);
}
return $this->marketo;
}
public function tokenRefreshCallback(AccessToken $token)
{
// CALLBACK FUNCTION TO STORE THE REFRESHED $token TO PERSISTENCE LAYER
}
}
$demoMarketoClient = new DemoMarketoClient()->getMarketoClient();
$options = [
"programName" => "My Marketo Program",
"batchSize" => 10
];
$campaigns = $demoMarketoClient->campaigns()->getCampaigns($options);
// getCampaigns() can also be called without options.
// $campaigns = { ... }