Last active
August 29, 2015 14:16
-
-
Save rossigee/2f2d628e22887e806f90 to your computer and use it in GitHub Desktop.
Checking/obtaining an OAuth2 session token w/CPD REST API v1
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
<?php | |
$params = array( | |
"client_id" => "683c5835a8d36a5bb974", | |
"client_secret" => "50ac9cb374989802d3d437c3fe0d7d8829c00e1b", | |
"username" => "[email protected]", | |
"password" => "theirpasswordhere", | |
"grant_type" => "password", | |
); | |
$postData = ""; | |
foreach($params as $k => $v) { | |
$postData .= $k . '='.urlencode($v).'&'; | |
} | |
$postData = rtrim($postData, '&'); | |
$url = "https://www.cpd.co.uk/restapi/v1/oauth2/access_token/"; | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
curl_setopt($curl, CURLOPT_POST, true); | |
curl_setopt($curl, CURLOPT_HEADER,'Content-Type: application/x-www-form-urlencoded'); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
$rawdata = curl_exec($curl); | |
print $rawdata; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment