いつもアドバイスをいただきありがとうございます。
YahooショッピングAPIを使って在庫参照をしています。下記PHPを実行しデータ自体はAPIで取得することができ、下記のように出力することに成功しました。
PHP
1$header = [ 2 'POST /ShoppingWebService/V1/getStock HTTP/1.1', 3 'Host: circus.shopping.yahooapis.jp', 4 'Authorization: Bearer ' . $refresh_token['access_token'] 5]; 6 7$url = 'https://circus.shopping.yahooapis.jp/ShoppingWebService/V1/getStock'; 8$param = array( 9 "seller_id" => 'shop', 10 "item_code" => 'ABC12345', 11); 12 13// 必要に応じてオプションを追加してください。 14$ch = curl_init(); 15curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); 16curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 17curl_setopt($ch, CURLOPT_URL, $url); 18curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 19curl_setopt($ch, CURLOPT_POST, true); 20curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param)); 21 22$response = curl_exec($ch); 23var_dump($response); 24curl_close($ch);
html
1<body cz-shortcut-listen="true"> 2 <resultset totalresultsavailable="1" totalresultsreturned="1" firstresultposition="1" ok="1" ng="0"> 3 <result> 4 <itemcode>ABC12345</itemcode> 5 <subcode></subcode> 6 <status>1</status> 7 <quantity>0</quantity> 8 <allowoverdraft>0</allowoverdraft> 9 <ispublished>1</ispublished> 10 <stockclose>0</stockclose> 11 <updatetime>2019-06-20T17:03:49+09:00</updatetime> 12 </result> 13 </resultset> 14</body>
この出力結果から「status」の値だけをPHPで取得したいのですが、なかなかうまくいきません・・・。何か良い方法はないでしょうか?
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/20 10:29