我在点击按钮时调用API
。 API会向我返回json
响应,我希望得到value
,但我收到此错误stdClass Object ( [Message] => An error has occurred. )
。
我正在使用CURL
进行API调用。我收到了回复,但是当我想解码它时,它给了我错误。以下是代码。
$curl = curl_init($api_url);
.....
$curl_response = curl_exec($curl);
$json=json_decode($curl_response);
print_r($curl_response);
die();
$meter_alive= $json->data->Response; // getting error here in the web
...
curl_response
为{"data":{"Response":"No"}}
,json encoded
回复为stdClass Object ( [Message] => An error has occurred. )
。
我还尝试将$json=json_decode($curl_response);
更改为$json=json_decode($curl_response, true);
,将$json=json_decode($curl_response);
更改为$json=(array)json_decode($curl_response);
但我仍然无法得到结果。我不知道实际问题是什么。
任何帮助都将受到高度赞赏。