Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 易趣交易API附加呼叫返回';无效的作业上下文类型';错误_Php_Soap_Ebay Api - Fatal编程技术网

Php 易趣交易API附加呼叫返回';无效的作业上下文类型';错误

Php 易趣交易API附加呼叫返回';无效的作业上下文类型';错误,php,soap,ebay-api,Php,Soap,Ebay Api,我正在尝试使用php和CURL在易趣上用易趣交易API列出一件物品 XML请求和CURL语法对我来说似乎很好,但API返回无效的作业上下文类型错误 我想我的标题遗漏了什么 我的请求代码如下: $xml_string = '<?xml version="1.0" encoding="utf-8"?> <AddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">

我正在尝试使用php和CURL在易趣上用易趣交易API列出一件物品

XML请求和CURL语法对我来说似乎很好,但API返回
无效的作业上下文类型
错误

我想我的标题遗漏了什么

我的请求代码如下:

$xml_string = '<?xml version="1.0" encoding="utf-8"?>
                        <AddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
                          <RequesterCredentials>
                            <eBayAuthToken>*Token*</eBayAuthToken>
                          </RequesterCredentials>
                          <ErrorLanguage>en_US</ErrorLanguage>
                          <WarningLevel>High</WarningLevel>
                          <Item>
                            <Title>'.$postdata['item_name'].'</Title>
                            <Description>'.$postdata['external_comments'].'</Description>
                            <PrimaryCategory>
                              <CategoryID>377</CategoryID>
                            </PrimaryCategory>
                            <StartPrice>'.$postdata['ebay_price'].'</StartPrice>
                            <CategoryMappingAllowed>true</CategoryMappingAllowed>
                            <Country>US</Country>
                            <Currency>USD</Currency>
                            <ConditionID>1000</ConditionID>
                            <DispatchTimeMax>3</DispatchTimeMax>
                            <ListingDuration>Days_7</ListingDuration>
                            <ListingType>Chinese</ListingType>
                            <PaymentMethods>PayPal</PaymentMethods>
                            <!--Enter your Paypal email address-->
                            <PayPalEmailAddress>jash389@gmail.com</PayPalEmailAddress>
                            <PictureDetails>
                              <PictureURL>http://pics.ebay.com/aw/pics/dot_clear.gif</PictureURL>
                            </PictureDetails>
                            <PostalCode>95125</PostalCode>
                            <Quantity>1</Quantity>
                            <ReturnPolicy>
                              <ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
                              <RefundOption>MoneyBack</RefundOption>
                              <ReturnsWithinOption>Days_30</ReturnsWithinOption>
                              <Description>If you are not satisfied, return the book for refund.</Description>
                              <ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
                            </ReturnPolicy>
                            <ShippingDetails>
                              <ShippingType>Flat</ShippingType>
                              <ShippingServiceOptions>
                                <ShippingServicePriority>1</ShippingServicePriority>
                                <ShippingService>USPSMedia</ShippingService>
                                <ShippingServiceCost>2.50</ShippingServiceCost>
                              </ShippingServiceOptions>
                            </ShippingDetails>
                            <Site>US</Site>
                         </Item>
                        </AddItemRequest>';

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.ebay.com/ws/api.dll");
        $headers = array(
            'Content-Type: text/xml',
            'X-EBAY-API-COMPATIBILITY-LEVEL: 967',
            'X-EBAY-API-DEV-NAME: ',
            'X-EBAY-API-APP-NAME: ',
            'X-EBAY-API-CERT-NAME: ',
            'X-EBAY-API-SITEID: 2',
            'X-EBAY-API-CALL-NAME: AddItems'
        );

        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "xmlRequest=" . $xml_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
$xml\u string=>
*代币*
恩努斯
高
“.$postdata['item_name']”
“.$postdata['external_comments']”
377
“.$postdata['ebay_price']”
真的
美国
美元
1000
3.
第7天
中国人
贝宝
jash389@gmail.com
http://pics.ebay.com/aw/pics/dot_clear.gif
95125
1.
接受退货
退款
第30天
如果您不满意,请退还该书以获得退款。
买主
平的
1.
美国药典
2.50
美国
';
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,”https://api.sandbox.ebay.com/ws/api.dll");
$headers=数组(
'内容类型:text/xml',
“X-EBAY-API-COMPATIBILITY-LEVEL:967”,
“X-EBAY-API-DEV-NAME:”,
“X-EBAY-API-APP-NAME:”,
“X-EBAY-API-CERT-NAME:”,
“X-EBAY-API-SITEID:2”,
'X-EBAY-API-CALL-NAME:AddItems'
);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_POSTFIELDS,“xmlRequest=”.$xml_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_头,FALSE);
curl_setopt($ch,CURLOPT_POST,TRUE);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,300);
答复是:

<?xml version="1.0" encoding="UTF-8"?>
  <AddItemsResponse xmlns="urn:ebay:apis:eBLBaseComponents">
  <Timestamp>2017-07-28T18:48:59.487Z</Timestamp>
  <Ack>Failure</Ack>
  <Errors>
      <ShortMessage>Invalid job context type</ShortMessage>
      <LongMessage>The job context object is not supported by Action Service Framework.</LongMessage>
     <ErrorCode>21843</ErrorCode>
     <SeverityCode>Error</SeverityCode>
     <ErrorParameters ParamID="0"><Value>AddItems</Value></ErrorParameters>
     <ErrorParameters ParamID="1"><Value>AddItemRequestType</Value></ErrorParameters>
     <ErrorClassification>RequestError</ErrorClassification>
 </Errors><Version>1021</Version><Build>E1021_UNI_API5_18478667_R1</Build></AddItemsResponse>

2017-07-28818:48:59.487Z
失败
无效的作业上下文类型
操作服务框架不支持作业上下文对象。
21843
错误
附加项
AddItemRequestType
请求错误
1021E1021_UNI_API5_18478667_R1
当我尝试使用API explorer使用相同的XML时。请求通过了


我想CURL有一些问题。

请指定X-EBAY-API-CALL-NAME作为附加项

您的XML是一个AddItemRequest


这些必须匹配。AddItem和AddItems是两个不同的电话。

嘿,谢谢你的回复。我今天就知道了。我现在被卡住的地方是装运细节部分。你知道那是什么吗。无论如何谢谢你!