Php Can';t访问Google Plus JSON中的附件数据

Php Can';t访问Google Plus JSON中的附件数据,php,arrays,json,object,google-plus,Php,Arrays,Json,Object,Google Plus,我正在访问Google Plus API,这是返回的结果之一: { "nextPageToken": "Ci8I0bJLEie2uAPcvrABl96xAdaVqgO93LADn_6ABO2vgwXqpbAFoNmEBsHCpwgYAgovCJXLThInn-8054qFArGHmQKtp-gD_r6-BOqlsAW-7uAGjO7QB4HbngqEoKkLGAEQj5e7jAUY8sK7jAUiAA", "items": [ { "id": "z13rwjqhyqzve5tgq0

我正在访问Google Plus API,这是返回的结果之一:

{
 "nextPageToken": "Ci8I0bJLEie2uAPcvrABl96xAdaVqgO93LADn_6ABO2vgwXqpbAFoNmEBsHCpwgYAgovCJXLThInn-8054qFArGHmQKtp-gD_r6-BOqlsAW-7uAGjO7QB4HbngqEoKkLGAEQj5e7jAUY8sK7jAUiAA",
 "items": [
  {
   "id": "z13rwjqhyqzve5tgq04cdxfyfzqtgfszfcw",
   "url": "https://plus.google.com/104261567553968048744/posts/SDs5inGSpEi",
   "actor": {
    "displayName": "Evan Parker",
    "url": "https://plus.google.com/104261567553968048744"
   },
   "verb": "post",
   "object": {
    "attachments": [
     {
      "objectType": "photo",
      "displayName": "#throughglass",
      "id": "104261567553968048744.5876882440165641794",
      "content": "s_00d2c678-b686-49db-9666-a55292cbe59b-0",
      "url": "https://plus.google.com/photos/104261567553968048744/albums/5876882440813674497/5876882440165641794?authkey=CM3iyKyWoa7gcA",
      "image": {
       "url": "https://lh5.googleusercontent.com/-aI28I0V0geM/UY7hcTjNzkI/AAAAAAABzYw/8MxNghGljew/w497-h373/s_00d2c678-b686-49db-9666-a55292cbe59b-0",
       "type": "image/jpeg",
       "height": 373,
       "width": 497
      },
      "fullImage": {
       "url": "https://lh5.googleusercontent.com/-aI28I0V0geM/UY7hcTjNzkI/AAAAAAABzYw/8MxNghGljew/s0-d/s_00d2c678-b686-49db-9666-a55292cbe59b-0",
       "type": "image/jpeg",
       "height": 1888,
       "width": 2560
      }
     }
    ]
   }
  },
  {
   "id": "z12zh1gopsqyep5ox04cef0rwqrtsl1ai54",
   "url": "https://plus.google.com/117367546931116283373/posts/THnmvu6e9FT",
   "actor": {
    "displayName": "Max Braun",
    "url": "https://plus.google.com/117367546931116283373"
   },
   "verb": "post",
   "object": {
    "attachments": [
     {
      "objectType": "photo",
      "displayName": "#throughglass, thanks @mattywyattmartin!",
      "id": "117367546931116283373.5876858377843226994",
      "content": "IMG_20130511_153648.jpg",
      "url": "https://plus.google.com/photos/117367546931116283373/albums/5876858374868052977/5876858377843226994?authkey=CPT71f-zl_iToQE",
      "image": {
       "url": "https://lh4.googleusercontent.com/-E_OT7cr5qj4/UY7LjsafuXI/AAAAAAAA1yg/RAEswDK1-iw/w497-h373/IMG_20130511_153648.jpg",
       "type": "image/jpeg",
       "height": 373,
       "width": 497
      },
      "fullImage": {
       "url": "https://lh4.googleusercontent.com/-E_OT7cr5qj4/UY7LjsafuXI/AAAAAAAA1yg/RAEswDK1-iw/s0-d/IMG_20130511_153648.jpg",
       "type": "image/jpeg",
       "height": 1276,
       "width": 1276
      }
     }
    ]
   }
  }
 ]
}
以下是我使用PHP访问它的方式:

$posts = json_decode($content);
foreach ($posts->items as $value){
    echo "<b>ID: </b>" . $id . "<br />";
    echo "<b>Name: </b>" . $value->actor->displayName . "<br />";
    echo "<b>Profile URL: </b>" . $value->actor->url . "<br />";
    echo "<b>Post URL: </b>" . $value->url . "<br />";
    echo "<b>Post Text: </b>" . $value->object->attachments->displayName . "<br />";
    echo "<b>Image Small: </b>" . $value->object->attachments->image->url . "<br />";
    echo "<b>Image Full: </b>" . $value->object->attachments->fullImage->url . "<br /><br />";
    $count++;
}
$posts=json\u decode($content);
foreach($posts->items as$value){
回显“ID:.$ID.”
; echo“Name:”.$value->actor->displayName。“
”; echo“Profile URL:”.$value->actor->URL.
; 回显“Post URL:”.$value->URL.
”; 回显“发布文本:”.$value->object->attachments->displayName。“
”; 回显“图像小:”.$value->object->attachments->Image->url。“
”; 回显“图像完整:”.$value->object->attachments->fullImage->url。“

”; $count++; }
由于某些原因,我无法获取附件数据,因为它嵌套在“对象”下。是否有一个修复或解决方法可以解决此问题?

echo“Post Text:”$值->对象->附件[0]->显示名称。“
”;
echo "<b>Post Text: </b>" . $value->object->attachments[0]->displayName . "<br />";
echo "<b>Image Small: </b>" . $value->object->attachments[0]->image->url . "<br />";
echo "<b>Image Full: </b>" . $value->object->attachments[0]->fullImage->url . "<br /><br />";
回声“图像小:”$值->对象->附件[0]->图像->url。“
”; 回显“图像已满:”$值->对象->附件[0]->完整图像->url。“

”;
附件部分是一个数组。因此,您需要通过它的数组索引访问它,然后才能访问数组中对象的属性