Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # FIRST CURL TO GET TOKEN
- #
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $PAYPAL_OAUTH_API);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_USERPWD, $PAYPAL_CLIENT . ':' . $PAYPAL_SECRET);
- $headers = array();
- $headers[] = 'Accept: application/json';
- $headers[] = 'Accept-Language: en_US';
- $headers[] = 'Content-Type: application/x-www-form-urlencoded';
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- $auth = curl_exec($ch);
- if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); }
- curl_close ($ch);
- $auth = json_decode($auth);
- #
- # SECOND CURL TO GET ORDER DETAILS
- #
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $PAYPAL_ORDER_API);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
- $headers = array();
- $headers[] = 'Content-Type: application/json';
- $headers[] = 'Authorization: Bearer ' . $token;
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- $details = curl_exec($ch);
- if (curl_errno($ch)) {
- echo 'Error:' . curl_errno($ch);
- }
- curl_close ($ch);
- $details = json_decode($details);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement