Skip to content

Instantly share code, notes, and snippets.

@3zzy
Created February 12, 2015 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3zzy/f6831eb33968ba3a53b7 to your computer and use it in GitHub Desktop.
Save 3zzy/f6831eb33968ba3a53b7 to your computer and use it in GitHub Desktop.
Get category list from eBay
<?php
$endpoint = "https://api.ebay.com/ws/api.dll";
$api_dev_name = "secret";
$api_app_name = "secret";
$api_cert_name = "secret";
$auth_token = "token";
$headers = array(
'Content-Type:text/xml',
'X-EBAY-API-COMPATIBILITY-LEVEL: 819',
'X-EBAY-API-DEV-NAME: '.$api_dev_name,
'X-EBAY-API-APP-NAME: '.$api_app_name,
'X-EBAY-API-CERT-NAME :'.$api_cert_name,
'X-EBAY-API-CALL-NAME: GetCategories',
'X-EBAY-API-RESPONSE-ENCODING : JSON',
'X-EBAY-API-REQUEST-ENCODING : JSON',
'X-EBAY-API-SITEID: 15' # eBay.com.au
);
$body = <<<BODY
<?xml version="1.0" encoding="utf-8"?>
<GetCategoriesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>$auth_token</eBayAuthToken>
</RequesterCredentials>
<ViewAllNodes>True</ViewAllNodes>
<DetailLevel>ReturnAll</DetailLevel>
</GetCategoriesRequest>
BODY;
$body = utf8_encode($body);
$curl = curl_init();
curl_setopt_array($curl,
array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $endpoint,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => $headers
)
);
$response = curl_exec($curl);
curl_close($curl);
if(!$response){
die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
}
else
{
echo $response;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment