Last active
October 18, 2019 03:15
-
-
Save thinkerman/7e5ca06b0051071add05393c1dc6322b to your computer and use it in GitHub Desktop.
Token generation function for Marketo REST API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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