Guest User

Untitled

a guest
Apr 18th, 2021
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. function authorise($clientId, $clientSecret
  2. $b64 = base64_encode($clientId.":".$clientSecret
  3. $cURLConnection = curl_init(
  4. $url = "https://api.sandbox.ebay.com/identity/v1/oauth2/token";
  5.  
  6. $postFields = array(
  7. 'grant_type' => 'client_credentials',
  8. 'scope' => 'https://api.ebay.com/oauth/api_scope'
  9. );
  10.  
  11. curl_setopt($cURLConnection, CURLOPT_URL, $url);
  12. curl_setopt($cURLConnection, CURLOPT_POST, true);
  13. curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, array(
  14. "Authorization:Basic $b64",
  15. "Content-Type:application/x-www-form-urlencoded"
  16. ));
  17.  
  18. curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, json_encode($postFields))
  19. $response = curl_exec($cURLConnection);
  20. curl_close($cURLConnection);
  21.  
  22. $result = json_decode($response, true);
Add Comment
Please, Sign In to add comment