dsztc99732
dsztc99732
2017-02-20 06:22

我如何提取我的JSON响应的这一部分

  • json
  • php

i can extract user id from JSON response,i get response from telegram bot API, but i can not extract file_id. here is my code:

 <?php
$response='{"ok":true,"result":[{"update_id":514191839,"message":{"message_id":898,"from":{"id":100000000,"first_name":"Nnn","username":"myid"},"chat":{"id":101150186,"first_name":"Nnn","username":"myid","type":"private"},"date":1487570256,"photo":[{"file_id":"AgADBAAD4KcxG9qfWFEqGZHRzv1IReOGnhkABOym5qINB41gwLIBAAEC","file_size":480,"width":90,"height":44},{"file_id":"AgADBAAD4KcxG9qfWFEqGZHRzv1IReOGnhkABCkXQqPZCWHswbIBAAEC","file_size":2694,"width":273,"height":132}]}}]}';
$arrayUpdate= json_decode($response, true);
foreach ($arrayUpdate['result'] as $key) {

                echo "user id is:".$key['message']['from']['id']."<br />";
                echo "photo file id is:".$key['photo']['file_id'];

}
?>
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐

换一换