获得错误信息-注意:试图在中获取非对象的属性--我正在尝试使用YELP进行实验/学习,但我被一条简单的错误消息困住了,我似乎找不出答案。以下内容:https://github.com/Yelp/yelp-api/tree/master/v2/php
function query_api($term, $location) {
$response = json_decode(search($term, $location));
$business_id = $response->businesses[0]->id;
print sprintf(
"%d businesses found, querying business info for the top result \"%s\"\n\n",
count($response->businesses),
$business_id
);
$response = get_business($business_id);
print sprintf("Result for business \"%s\" found:\n", $business_id);
print "$response\n";}
调用函数
$longopts = array(
"term::",
"location::",
);
$options = getopt("", $longopts);
$term = $options['term'] ?: '';
$location = $options['location'] ?: '';
query_api($term, $location); 发布于 2015-11-01 18:56:21
此通知表示$response不是一个对象,您正在尝试访问不存在的属性businesses。
使用var_dump($response)获取有关此变量的信息。
https://stackoverflow.com/questions/33465764
复制相似问题