Skip to content

Instantly share code, notes, and snippets.

@thinkerman
Last active October 18, 2019 03:15
Show Gist options
  • Save thinkerman/7e5ca06b0051071add05393c1dc6322b to your computer and use it in GitHub Desktop.
Save thinkerman/7e5ca06b0051071add05393c1dc6322b to your computer and use it in GitHub Desktop.
Token generation function for Marketo REST API
define ("MKTO_HOST", "**Your Marketo host**");
define ("MKTO_CID", "**Your Marketo Client ID");
define ("MKTO_CS","**Your Marketo Client Seccret");
//generate token
function generate_token(){
$ch = curl_init(MKTO_HOST . "/identity/oauth/token?grant_type=client_credentials&client_id=" . MKTO_CID . "&client_secret=" . MKTO_CS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',));
$response = json_decode(curl_exec($ch));
curl_close($ch);
$token = $response->access_token;
return $token;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment