Reputation: 3840
Building an Facebook Video application. Users can Favorite videos by using in app og.like.
I use
$response = $facebook->api(
'me/og.likes',
'GET'
and i will get
"data": {
"object": {
"id": "1399918593560042",
"url": "http://some_url.com",
"type": "video.tv_show",
"title": "the_video_title"
}
To get url i use.
$response = $facebook->api(
'me/og.likes?app_id_filter=381977341837631',
'GET'
);
foreach ( $response['data'] as $data );
$Object = $data['data']['object'];
Then
<li class="program"><a class="thumbnail" data-transition="slide" href="<?php echo $Object['url']; ?>">
<img src="IMG_URL"></a></li>
The issue is to display the image. If i click the ID in graph API i will get
{
"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
}
My question is. How do i display the image ?
Upvotes: 2
Views: 737
Reputation: 20753
After you get the $Object
, make the \GET
request to this object-
$resp = $facebook->api($Object['id']);
Then fetch the image urls from the response-
if(isset($resp['image']))
{
foreach ($resp['image'] as $image)
{
echo $imag_url = $image['url'];
}
}
Upvotes: 1
Reputation: 620
Basically you'll need to make a request with the Object id to get the desired image from Facebook Graph.
So, after you assign $Object = $data['data']['object'] You can simply get the JSON from http://graph.facebook.com/$Object['id'] and to get the image.
Example code:
$facebookJSON = file_get_contents("https://graph.facebook.com/" . $Object['id']);
$myArr = json_decode($facebookJSON, 1);
$myImage = $myArr['image']['url'];
$myImage will be the object image url.
Good Luck, Guy.
Upvotes: 1