Skip to content

Instantly share code, notes, and snippets.

@nathanaelphilip
Created September 25, 2013 14:37
Show Gist options
  • Save nathanaelphilip/6700563 to your computer and use it in GitHub Desktop.
Save nathanaelphilip/6700563 to your computer and use it in GitHub Desktop.
ini_set('error_reporting', E_ALL);
echo "hallo";
$username = 'EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp';
$password = 'EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp';
$headers = array('Accept: application/json','Accept-Language: en_US');
$data = array('grant_type' => 'client_credentials');
$ch = curl_init('https://api.sandbox.paypal.com/v1/oauth2/token');
curl_setopt($ch, CURLOPT_URL, 'https://api.sandbox.paypal.com/v1/oauth2/token');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ( curl_errno($ch) ) {
$ex = curl_error($ch);
#$ex = curl_errno($ch);
curl_close($ch);
}
curl_close($ch);
print_r($ex);
print_r($results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment