在Graph API> Photo中,我使用下面的脚本来获取Photo属性
$response = file_get_contents($token_url);
if($response=='') { echo "<script>window.location='index.php'</script>"; }
$params = null;
parse_str($response, $params);
$fb_photo_id='10150361640936173';
$graph_url_photos = "https://graph.facebook.com/" . $fb_photo_id . "?access_token="
. $params['access_token'];
$photos = json_decode(file_get_contents($graph_url_photos));
}
("token " . $params['access_token']);
echo $photos_id=$photos->id; echo "</br>";
问题:如何获取$photos->tags
的数据?
答案 0 :(得分:1)
这是您访问它的方式:
<?php
// ... your code here...
if(!empty($photos->tags)) {
foreach($photos->tags->data as $tag)
echo "ID: {$tag->id}<br />Name: {$tag->name}<br />X: {$tag->x}<br />Y: {$tag->y}<br />Created on: {$tag->created_time}<br /><br />";
}
答案 1 :(得分:0)
您可以使用此页面测试Graph API调用: https://developers.facebook.com/tools/explorer
就你的例子而言:https://developers.facebook.com/tools/explorer?method=GET&path=10150361640936173
你会看到“标签”结构是这样的:
"tags": {
"data": [
{
"id": "1696691267",
"name": "黃柏淇",
"x": 64.375,
"y": 80.2619,
"created_time": "2011-11-07T09:12:22+0000"
},
{
"id": "1705329218",
"name": "Austin Ng",
"x": 80.4543,
"y": 48.0512,
"created_time": "2011-11-07T09:12:22+0000"
}
]
},