私は写真ファイルIDを取得します。jsonデコードコールテレグラムapi
file_get_contents('php://input'):
{
"update_id": 399206890,
"message": {
"message_id": 149,
"from": {
"id": 81777999,
"is_bot": false,
"first_name": "@goldenguardbot",
"last_name": "✅",
"username": "amirntm",
"language_code": "en-US"
},
"chat": {
"id": 81777999,
"first_name": "@goldenguardbot",
"last_name": "✅",
"username": "amirntm",
"type": "private"
},
"date": 1507643430,
"photo": [
{
"file_id": "AgADBAADpaoxG6lZ6VIeePTlKxaJsl3X-RkABPbjyThHJgF7FLwBAAEC",
"file_size": 1639,
"file_path": "photos/file_4.jpg",
"width": 90,
"height": 72
},
{
"file_id": "AgADBAADpaoxG6lZ6VIeePTlKxaJsl3X-RkABIrarvPZGVNGFrwBAAEC",
"file_size": 22230,
"width": 320,
"height": 256
},
{
"file_id": "AgADBAADpaoxG6lZ6VIeePTlKxaJsl3X-RkABKFhu79tL5EBF7wBAAEC",
"file_size": 95422,
"width": 800,
"height": 640
},
{
"file_id": "AgADBAADpaoxG6lZ6VIeePTlKxaJsl3X-RkABGzlLqe_Yv0PFbwBAAEC",
"file_size": 172689,
"width": 1160,
"height": 928
}
]
}
}
私はファイルIDをどのように取得しますか? 例:
$update->message->photo->file_id;
'$ update-> message->写真[0] - > file_id' – WillardSolutions
[json_decode()](http://php.net/manual/en/function。 json-decode.php) – RiggsFolly
jsonの文字列表記を理解できない場合は、常に '$ t = json_decode($ your_json_string);を実行します。 print_r($ t); ' – RiggsFolly