eBay get all business policies of a seller account in JSON format




<?php
ini_set('max_execution_time',0);

//Call this function to which headers will be passed
function getCallResponse($headers)
{
    $url= utf8_encode("https://svcs.sandbox.ebay.com/services/selling/v1/SellerProfilesManagementService");//URL to which API will be called
    $ch = curl_init($url);//cURL initialisation
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);    // set headers using $headers array
    curl_setopt($ch, CURLOPT_POST, true);              // POST request type
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlrequest); // set the body of the POST
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// return values as a string, not to std out
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 400);
    $content=curl_exec($ch);
    curl_close($ch);
    $resp = simplexml_load_string($content);
    return $resp;//returns the response array


//Check to see if the request was successful
function InitializeGetSellerProfilesCall($api_params)
{
    $headers = getHeaders($api_params);
    $resp = getCallResponse($headers);
    if($resp->ack != 'Success')
    {
        echo 'Could not succeed to call the getSellerProfiles API';
    }
    else
    {
    echo json_encode($resp);
    }
}

//Headers to be set for the request
function getHeaders($params)
{
    $headers =  array(
        'X-EBAY-SOA-OPERATION-NAME: getSellerProfiles',
        'X-EBAY-SOA-SECURITY-TOKEN: '.$params['token'],
        'X-EBAY-SOA-GLOBAL-ID: '.$params['siteID']
    );
    return $headers;
}

//
InitializeGetSellerProfilesCall(array(
    'token'=>'YOUR_AUTH_N_AUTH_TOKEN',//Auth'n'Auth Token of the developer account associated with the seller account
    'siteID'=>'EBAY-US'
));
echo "Done fetching seller business policy data";
?>

Comments