响应ebay类别数据不返回json数据

时间:2015-09-09 10:47:19

标签: php json curl categories ebay-api

我收到了返回ebay类别数据但未正确格式化,我想以JSON格式回复,

<?php 
   $app_id="xxxxxxx";
   $dev_id ="xxxxxxx";
   $cert_id="xxxxxxx";
   $call_name="GetCategoryInfoRequest";
   $token="xxxxxxxx";
   $site_id = 0;
   $compat_level=819;

  $xml_request ="<?xml version='1.0' encoding='utf-8'?>
<GetCategoryInfoRequest xmlns='urn:ebay:apis:eBLBaseComponents'>
   <CategoryID>-1</CategoryID>
   <RequesterCredentials><eBayAuthToken>".$token."</eBayAuthToken>
    </RequesterCredentials>
   <IncludeSelector>ChildCategories</IncludeSelector>
</GetCategoryInfoRequest>";
$endpoint = "https://api.ebay.com/ws/api.dll";



    $headers = array(
        'X-EBAY-API-COMPATIBILITY-LEVEL: 819',
        'X-EBAY-API-DEV-NAME: '.$dev_id,
        'X-EBAY-API-APP-NAME: '.$app_id,
        'X-EBAY-API-CERT-NAME: '.$cert_id,
        'X-EBAY-API-CALL-NAME: GetCategories',
        'X-EBAY-API-OPERATION-NAME: GetCategories',
        'X-EBAY-API-RESPONSE-ENCODING:JSON',
        'X-EBAY-API-SITEID: 0',
        'Content-Type:text/XML'
    );

    $xmlRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
    $xmlRequest .= "<GetCategoriesRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">";
    $xmlRequest .= "<RequesterCredentials>";
    $xmlRequest .= "<eBayAuthToken>{$token}</eBayAuthToken>";
    $xmlRequest .= "</RequesterCredentials>";
    $xmlRequest .= "<CategorySiteID>0</CategorySiteID>";
    $xmlRequest .= "<DetailLevel>ReturnAll</DetailLevel>";
    $xmlRequest .= "</GetCategoriesRequest>";
    $xmlRequestEncode = ($xmlRequest);

当我使用ebay(上方)向curl请求时,我收到了未格式化的类别响应数据(如下所示),我从ebay api获得了类别响应数据,I无法读取响应数据,但格式不JSON,我想要JSON响应数据。有什么建议吗?

  

2015-09-09T10:24:56.505ZSuccess933E933_CORE_APICATALOG_17621198_R1truetrue200811Antiques20081truetrue379032Antiquities20081truetrue379083The   Americas37903truetruetrue1629223Byzantine37903truetruetrue1629233Celtic37903truetruetrue379053Egyptian37903truetruetrue1629163Far   Eastern37903truetruetrue379063Greek37903truetruetrue1629173Holy   Land37903truetruetrue1629183Islamic37903truetruetrue911013Near   Eastern37903truetruetrue668343Neolithic&amp;   Paleolithic37903truetruetrue379073Roman37903truetruetrue1629193South   Italian37903truetruetrue1629203Viking37903truetruetrue1629213Reproductions37903truetruetrue1711693Price   指南&amp; Publications37903truetruetrue734643Other   古物37903truetruetrue47072Architectural&amp;   Garden20081truetrue1629253Balusters4707truetruetrue1629263Barn   Doors4707truetruetrue1629273Beams4707truetruetrue379093Ceiling   Tins4707truetruetrue635163Chandeliers,Fixtures,   Sconces4707truetruetrue1629283Columns&amp;   Posts4707truetruetrue1629293Corbels4707truetruetrue379103Doors4707truetruetrue635173Finials4707truetruetrue635183Fireplaces   &安培;   Mantels4707truetruetrue47083Garden4707truetruetrue379113Hardware4707truetrue379124Door   贝尔斯&amp; Knockers37911truetruetrue379144Door Knobs&amp;   Handles37911truetruetrue379164Door Plates&amp;   Backplates37911truetruetrue1629334Drawer   Pulls37911truetruetrue1629344Ecutcheons&amp;关键孔   Covers37911truetruetrue1629354Heating Grates&amp;   Vents37911truetruetrue379134Hooks&amp;   Brackets37911truetruetrue379154Locks&amp;   Keys37911truetruetrue1629304 ....................等等

0 个答案:

没有答案