我正在使用Unirest PHP调用API。它看起来像这样:
$response = Unirest\Request::post(
"url_to_api",
array(
"api" => "my_api_key",
"Content-Type" => "application/json"
)
json_encode(array("parameters" => [100, 200]))
);
print_r($response->body);
响应正文包含很多信息。这是一个stdClass对象。我怎么解析这个?我尝试像在JSON中那样解析它,但是我收到了一个错误。响应如下:
stdClass Object ( [requestId] => blahblah [status] => Succeeded [elapsedTimeInMs] => 0 [warnings] => Array ( [0] => elapsedTimeInMs is deprecated. Please use the timing headers instead. [1] => status is deprecated. Please use HTTP status codes to determine the status of a request. ) [release] => stdClass Object ( [version] => 13 [commitId] => 275342fakeid5737425 [file] => test.R [function] => add_nums ) [result] => Array ( [0] => 300 ) )
我想要的只是响应中的300,发生在最后。