简体   繁体   English

尝试使用Yelp API PHP

[英]Experimenting with Yelp API PHP

Getting the Error Message - Notice: Trying to get property of non-object in I'm trying to experiment/learn with the YELP API but I'm getting stuck with a simple error message, I can't seem to figure out. 获取错误消息 - 注意:尝试获取非对象的属性我正在尝试使用YELP API进行实验/学习但是我遇到了一个简单的错误消息,我似乎无法弄明白。 Following this: https://github.com/Yelp/yelp-api/tree/master/v2/php 接下来: 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";

} }

Calling the function 调用函数

$longopts  = array(
"term::",
"location::",
);

$options = getopt("", $longopts);

$term = $options['term'] ?: '';
$location = $options['location'] ?: '';

query_api($term, $location);   

This notice indicates that $response is not an object and you are trying to access a property businesses that doesn't exist. 此通知表明$response不是对象,您尝试访问不存在的属性businesses
Use var_dump($response) to get information about this variable. 使用var_dump($response)获取有关此变量的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM