我通过 cURL / json_decode() 获得了以下 stdObject:
stdClass Object
(
[response] => stdClass Object
(
[status] => OK
[num_elements] => 1030
[start_element] => 0
[results] => stdClass Object
(
[publisher] => stdClass Object
(
[num_elements] => 1030
[results] => Array
(
[0] => stdClass Object
(
[id] => 1234
[weight] => 4444
[name] => Pub 1
[member_id] => 1
[state] => active
[code] =>
)
[1] => stdClass Object
(
[id] => 1235
[weight] => 4444
[name] => Pub 2
[member_id] => 2
[state] => active
[code] =>
)
)
)
)
[dbg_info] => stdClass Object
(
[instance] => instance1.server.com
[slave_hit] => 1
[db] => db1.server.com
[reads] => 3
[read_limit] => 100
[read_limit_seconds] => 60
[writes] => 0
[write_limit] => 60
[write_limit_seconds] => 60
[awesomesauce_cache_used] =>
[count_cache_used] =>
[warnings] => Array
(
)
[time] => 70.440053939819
[start_microtime] => 1380833763.4083
[version] => 1.14
[slave_lag] => 0
[member_last_modified_age] => 2083072
)
)
)
我正在遍历它以获得每个结果的 ID:
foreach ($result->response->results->publisher->results as $object) {
$publishers .= $object->id.",";
}
尽管代码运行良好,但 PHP 正在发出以下通知/警告:
PHP 注意:试图在第 1 行的 /var/www/vhosts/domain.net/script.php 中获取非对象的属性 PHP 注意:试图在 /var/www/vhosts/domain 中获取非对象的属性。第 1 行的 net/script.php PHP 警告:在第 1 行的 /var/www/vhosts/domain.net/script.php 中为 foreach() 提供的参数无效
有任何想法吗?提前致谢!