构建一个Facebook视频应用程序。用户可以在应用程序og.like中使用喜爱的视频。
我使用
$response = $facebook->api(
'me/og.likes',
'GET'
我会得到
"data": {
"object": {
"id": "1399918593560042",
"url": "http://some_url.com",
"type": "video.tv_show",
"title": "the_video_title"
}
为了得到我使用的url。
$response = $facebook->api(
'me/og.likes?app_id_filter=381977341837631',
'GET'
);
foreach ( $response['data'] as $data );
$Object = $data['data']['object'];
然后
<li class="program"><a class="thumbnail" data-transition="slide" href="<?php echo $Object['url']; ?>">
<img src="IMG_URL"></a></li>
问题是如何显示图像。如果我单击图形API中的ID,我将得到
{
"id": "1399918593560042",
"url": "http://some_url.com",
"type": "video.tv_show",
"title": "the_video_title",
"image": [
{
"url": "https://v.redli.se/p/102/sp/10200/thumbnail/entry_id/0_53lzx39w/width/1024/height/720",
"secure_url": "https://v.redli.se/p/102/sp/10200/thumbnail/entry_id/0_53lzx39w/width/1024/height/720",
"type": "image/jpg",
"width": 1024,
"height": 576
}
我的问题是。如何显示图像?
发布于 2013-08-13 03:04:37
得到$Object
后,向这个对象发出\GET
请求-
$resp = $facebook->api($Object['id']);
然后从响应中获取图像urls
if(isset($resp['image']))
{
foreach ($resp['image'] as $image)
{
echo $imag_url = $image['url'];
}
}
发布于 2013-08-06 06:22:35
基本上,您需要使用对象id发出请求才能从FacebookGraph中获取所需的图像。
因此,在分配$Object = $data'data‘数据之后,您可以从http://graph.facebook.com/$Object’‘id’获取JSON并获取图像。
示例代码:
$facebookJSON = file_get_contents("https://graph.facebook.com/" . $Object['id']);
$myArr = json_decode($facebookJSON, 1);
$myImage = $myArr['image']['url'];
$myImage将是对象图像url。
好运,盖伊。
https://stackoverflow.com/questions/18078346
复制