2013-03-12 169 views
0

我想用API在Sears marketplace中更新我的庫存。PHP:使用cURL發送XML數據PUT

庫存管理: 此API調用使用PUT方法來管理您的物品的庫存水平爲避免出錯,庫存更新應該只給那些成功處理項目進行注:。庫存不自動遞減,所以在接收和處理訂單時更新庫存非常重要。「

PUT網址:https://seller.marketplace.sears.com/SellerPortal/api/inventory/fbm-lmp/v6?email={emailaddress}&password={password}

XSD: https://seller.marketplace.sears.com/SellerPortal/s/schema/rest/inventory/import/v6/store-inventory.xsd?view=markup

示例XML:https://seller.marketplace.sears.com/SellerPortal/s/schema/samples/rest/inventory/import/v6/store-inventory.xml?view=markup

API文檔:
http://searsmarketplace.force.com/articles/FAQ/XML-How-do-I-update-inventory?retURL=%2Fapex%2FknowledgeProduct%3Fc%3DContent%26k%3D&popup=false

我創建如下因素腳本,但不能正常工作:

$xml = '<?xml version="1.0" encoding="UTF-8"?> 
    <store-inventory 
     xmlns="http://seller.marketplace.sears.com/catalog/v2" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://seller.marketplace.sears.com/SellerPortal/s/schema/rest/inventory/import/v2/store-inventory.xsd"> 
     <item item-id="10"> 
      <locations> 
       <location location-id="21"> 
        <quantity>20</quantity> 
        <pick-up-now-eligible>false</pick-up-now-eligible> 
       </location> 
      </locations> 
     </item> 
    </store-inventory>'; 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_VERBOSE, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_URL, "https://seller.marketplace.sears.com/SellerPortal/api/inventory/fbm-lmp/v6?email={email}&password={pass}"); 
curl_setopt($ch, CURLOPT_PORT, 443); 
curl_setopt($ch, CURLOPT_PUT, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS,array($xml)); 
$http_result = curl_exec($ch); 
if($http_result){ 
    echo $http_result; 
}else{ 
    echo curl_error($ch); 
} 

curl_close($ch); 

curl_error:

Unknown SSL protocol error in connection to seller.marketplace.sears.com:443

我哪裏錯了?

+0

http://stackoverflow.com/questions/3958226/using-put-method-with-php-curl-library – 2013-03-12 09:52:27

+0

和你的問題是什麼?錯誤的含義是什麼?如果是這樣,這裏的信息可能是有用的:[3未知SSL協議錯誤的常見原因cURL (2010年3月18日,由Chris Mahns提供)](http://blog.techstacks.com/2010/03/3-common -causes-of-unknown-ssl-protocol-errors-with-curl.html) – hakre 2013-03-12 10:01:33

+0

另外'CURLOPT_POSTFIELDS'與PUT無關 – hakre 2013-03-12 10:06:38

回答

-1

你可以試試這個:

curl_setopt($ch, CURLOPT_FAILONERROR,1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$result = curl_exec($ch); 
curl_close($ch);