Groups > Ebay > Ebay Legacy XML API > Re: Help migrating PHP script




Re: Help migrating PHP script

Re: Help migrating PHP script
Mon, 15 May 2006 13:34:15 -070
Hi cory heres a working example..

[pre]
<?php	
$userToken = '';

//access file as ex. file.php?cat=58058&SiteId=1&page=1

$eBayAPIURL = "https://api.ebay.com/ws/api.dll";
$COMPATIBILITYLEVEL = 433;

// Set these to your own IDs
$DEVNAME = '';
$APPNAME = '';
$CERTNAME= '';

$SESSIONCERTIFICATE = "$DEVNAME;$APPNAME;$CERTNAME";

//$SiteId = 3;
$callname = "GetCategoryListings";

// XML Request

$post_data = '<?xml version="1.0" encoding="utf-8"
?>';
$post_data .= '<GetCategoryListingsRequest
xmlns="urn:ebay:apis:eBLBaseComponents">';
$post_data .=
"<RequesterCredentials><eBayAuthToken>$userToken</eBayAuthTo
ken></RequesterCredentials>";
$post_data .= "<CategoryID>$cat</CategoryID>";
$post_data .= "<Pagination>";
$post_data .= "<EntriesPerPage>20</EntriesPerPage>";
$post_data .= "<PageNumber>$page</PageNumber>";
$post_data .= "</Pagination>";
$post_data .= '</GetCategoryListingsRequest>';
		

// eBay Header Settings
$ebayapiheader = array (
"X-EBAY-API-COMPATIBILITY-LEVEL: $COMPATIBILITYLEVEL",
"X-EBAY-API-SESSION-CERTIFICATE: $SESSIONCERTIFICATE",
"X-EBAY-API-DEV-NAME: $DEVNAME",
"X-EBAY-API-APP-NAME: $APPNAME",
"X-EBAY-API-CERT-NAME: $CERTNAME",
"X-EBAY-API-CALL-NAME: $callname",
"X-EBAY-API-SITEID: $SiteId" );


// The cURL request
$ch = curl_init();
$res= curl_setopt ($ch, CURLOPT_URL,$eBayAPIURL);

curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt ($ch, CURLOPT_HEADER, 0); // 0 = Don't give me the return header
curl_setopt($ch, CURLOPT_HTTPHEADER, $ebayapiheader); // Set this for eBayAPI
curl_setopt($ch, CURLOPT_POST, 1); // POST Method
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); //My XML Request
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$body = curl_exec ($ch); //Send the request
echo curl_error($ch);
curl_close ($ch); // Close the connection

// Output Reply to Browser
header("Content-type: application/xml");

print $body;
?>

Post Reply
about | contact