LoginSignup
1
1

More than 5 years have passed since last update.

Yahoo注文APIへのリクエストパラメータの書き方がわからない

Last updated at Posted at 2016-08-22

Yahoo APIの注文検索APIへのリクエストパラメータの書き方がわからず困窮しております。
リクエストURL
https://test.circus.shopping.yahooapis.jp/ShoppingWebService/V1/orderList

下記のソースの「$params」でパラメータを設定しています。
他にも、多重配列やXMLも試してみましたがいずれもうまくいきません。

$params = array(
    '/Req/SellerId'=>'snbx-xxxxxxx',
    '/Req/Search/Field'=>'OrderId',
    '/Req/Search/Condition/OrderTimeFrom'=>$OrderTimeFrom,
    );

$headers = array(
    'Content-Type: application/x-www-form-urlencoded',
    'Authorization: Bearer '.$access_token,
    );

$options = array(
    'http'=>array(
        'method'=>'POST',
        'content'=>http_build_query( $params ),
        'header'=>implode( "\r\n", $headers ),
        )
    );
$stream = stream_context_create( $options );

$order_result = file_get_contents( ORDERLIST_URL, FALSE, $stream );
print_r( array($order_result, $options));

上記のコードを実行すると「HTTP/1.0 400 Bad Request」が戻ります。
yahooのエラーコード一覧を見る限りでは「リクエストパラメータエラー」とあるのですが
正しい書き方を見つけられず何日も経過してしまっている状況です。
http://developer.yahoo.co.jp/webapi/shopping/orderList.html

先ほどのコードを実行した時の結果は下記のとおりです。

Warning: file_get_contents(https://test.circus.shopping.yahooapis.jp/ShoppingWebService/V1/orderList): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
in /xxx.php on line 107
Array
(
[0] =>
[1] => Array
(
[http] => Array
(
[method] => POST
[content] => %2FReq%2FSellerId=snbx-xxxxxxx&%2FReq%2FSearch%2FField=OrderId&%2FReq%2FSearch%2FCondition%2FOrderTimeFrom=20160822111650
[header] => Content-Type: application/x-www-form-urlencoded
Authorization: Bearer XEYz3e・・・
)
)
)

ご教授お願い致します。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1