从{<1}}获取:
json
返回:
https://api.telegram.org/--token--/getUpdates
现在我想获得stdClass Object
(
[ok] => 1
[result] => Array
(
[0] => stdClass Object
(
[update_id] => 122101947
[message] => stdClass Object
(
[message_id] => 36
[from] => stdClass Object
(
[id] => 88132232
[is_bot] =>
[first_name] => Mike
[last_name] => Christ
[username] => mike_ch
[language_code] => en
)
[chat] => stdClass Object
(
[id] => 88132232
[first_name] => Mike
[last_name] => Christ
[username] => mike_ch
[type] => private
)
[date] => 1512046846
[contact] => stdClass Object
(
[phone_number] => +905394792446
[first_name] => Mike
[last_name] => Christ
[user_id] => 88132232
)
)
)
)
)
:
phone_number
它什么都不返回,错误日志是:
PHP注意:未定义的属性:stdClass :: $ contact in /home/xxx/public_html/public_projects/xxx/seller/modules/telegram.php 在第10行
PHP注意:尝试获取非对象的属性 /home/xxx/public_html/public_projects/xxx/seller/modules/telegram.php 在第10行
但我能够成功$update = json_decode(file_get_contents($getUpdate));
echo $update->result[0]->message->contact->phone_number;
或date
这样:
chat
有什么建议吗?
修改:我的echo $update->result[0]->message->chat->first_name;
代码:
php