question

anmcdo_85 avatar image
0 Likes"
anmcdo_85 asked ·

I am trying to actually connect to the ebay API and keep getting a 302 error code

I have been banging my head against a brick wall for about a day now. All i want to do is actually connect to the ebay API using curl , i have managed to retrieve a security token, but when i try to use it to do a call to https://api.ebay.com/post-order/v2/cancellation/search i get a 302 error. My Code is below: $cSession = curl_init(); $clientId="IXXXXXXXXXXXXXXX"; $clientSecret="XXXXXXXXXXXXXXXXX"; $ContentType = "application/x-www-form-urlencoded"; $Authorization ="Basic ".base64_encode($clientId.":".$clientSecret); $redirectUri = "XXXXXXXXXXXXXXX"; $grantType = "client_credentials"; $scope = " https://api.ebay.com/oauth/api_scope";; $headers =[ "Content-Type: $ContentType", "Authorization: $Authorization" ]; $post = [ 'grant_type' => $grantType, 'redirect_uri' => $redirectUri, 'scope' => $scope ]; curl_setopt($cSession, CURLOPT_URL," https://api.ebay.com/identity/v1/oauth2/token";); curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers); curl_setopt($cSession, CURLOPT_POST,1); curl_setopt($cSession, CURLOPT_RETURNTRANSFER,1); curl_setopt($cSession, CURLOPT_POSTFIELDS, http_build_query($post)); $result=curl_exec($cSession); $result = json_decode($result); curl_close($cSession); $headers2 = [ 'Authorization' => 'Bearer '.$result->access_token, 'X-EBAY-C-MARKETPLACE-ID' => 'EBAY_US', 'Content-Type' => 'application/json', 'Accept' => 'application/json' ]; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_HTTPHEADER => $headers2, CURLOPT_HEADER => 1, CURLOPT_URL => ' https://api.ebay.com/post-order/v2/cancellation/search' )); $result2 = curl_exec($curl); var_dump($result2); any help would be greatly appreciated.
apihelphelp requiredcurl302301
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.