Question by anmcdo_85 · Oct 04, 2018 at 07:11 AM · curlapi301302helphelp required
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.
Comment
Your answer

Follow this Question
Related Questions
How to get buyer return requests using api? 0 Answers
API call for Reort Buyer in returns 1 Answer