PHP:使用 cURL PUT 发送 XML 数据

标签 php xml ssl curl

<分区>

我想使用 API 更新我在 Sears marketplace 中的库存。

库存管理: 此 API 调用使用 PUT 方法来管理商品的库存水平。为避免错误,应仅对已成功处理的项目进行库存更新。注意:库存不会自动减少,因此您在收到和处理订单时更新库存非常重要。”

PUT URL: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

我哪里错了?

最佳答案

你可以试试这个:

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);

关于PHP:使用 cURL PUT 发送 XML 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15357220/

上一篇:python - Facebook 不会在 PySide qwebview 中加载

下一篇:java - 如何从 servlet 验证连接是使用双向 SSL 建立的?

相关文章:

php - Paypal "we were unable to decrypt the certificate ID'

php - 检查图像修改时间的 HTACCESS 图像缓存规则

sql-server - 验证 xml 节点是否具有给定值 sql 的子节点

php - C - 编写自定义处理程序

php - Mysql编码问题

iOS HTTPS 请求 101

ssl - QM具有特殊字符时,WMQ自签名SSL相互身份验证失败

android - 打开安全的 websocket 连接时出现意外异常

java - 如何读取xml的头部

android - 如何在 XML 中定义屏幕尺寸的一半