Facebook Graph API - How to loop through all albums - php

I'm using the Facebook PHP SDK with Laravel and I need to loop through all photos in all albums and I'm struggling a little!
What I have at the minute is:
$request = new FacebookRequest(
$session,
'GET',
'/{username}/photos'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
print_r($graphObject);
this outputs JSON which I can't seem to find an easy way to loop and pull out the source for all the images. Does the SDK have some nice functions to grab the images for me?
Cheers,
Nick

Related

Facebook API obtain photos

I am looking for a fairly simple way of obtaining pictures from Facebook. I have a client that has pictures that he uploads to Facebook quite often. He wants a way for those pictures to be populated on the website that I built for him a while ago. I thought doing it with google drive would be a fairly easy solution for him, but it has not been.
I am trying to create a simple page that grabs his folders that the images live in with the graph api, without having to do a lot or having users logged in. What is going to be the easiest way of doing this?
I tried the explorer for the api and have the following code.
<?php
$request = new FacebookRequest(
$session,
'GET graph.facebook.com',
'/me',
array(
'fields' => 'id,name,photos{album}'
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
?>
I for now would just like to be able to echo the elements so that I can learn how it works, after that I can refine it. What am I doing wrong?

Get Facebook Video Thumbnails Large Size using Facebook Video ID - PHP

Hello I have checked many Stackoverflow questions regarding this. Following is the list of questions which I have seen:
Get Facebook video thumbnail image URLs?
How to get Facebook video thumbnail from its video id?
How to get big facebook video thumbnail
How to get facebook video thumbnail from a given video ID using php
Get large facebook video thumbnail using graph
But I got answer from no where.
I used this: https://graph.facebook.com/VIDEO_ID/picture, it worked but giving me very small thumbnail.
Please help me if you have got any way for this. Thanks in advance
I find how get thumbnail high solution using and i success get thumbnail high solution. You can using bellow code:
$video_id= Input::get('id_video');
$config = [
'app_id' => \Config::get('setting.APP_ID'),
'app_secret' => \Config::get('setting.SECRET_ID'),
'default_graph_version' => 'v2.7',
];
$fb = new Facebook($config);
$accessToken = Input::get('access_token');
$url = "https://graph.facebook.com/".$video_id."?fields=description,thumbnails&access_token=".$accessToken;
//Make the API call
$result = file_get_contents($url);
//Decode the JSON result.
$decoded = json_decode($result, true);
//Dump it out onto the page so that we can take a look at the structure of the data.
var_dump($decoded);
$accessToken I get from Graph explorer tool, Or you code function login facebook you can get access_token.
https://developers.facebook.com/docs/php/howto/example_facebook_login
I Hope help you!
Same you, I using Graph explorer can get thumbnails video but I cant get thumbnails from "https://graph.facebook.com/VIDEO_ID/picture". You can refe follow
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/{video-id}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

Facebook payments - how to get application token and give it to graph api

I'm trying to implement Facebook payments (on canvas), what I've got so far, is that FB is calling my callback URL, I can get the payment's ID, and now I'm supposed to call Graph Api to get the details. And this is what I can't do.
Here ( https://developers.facebook.com/docs/graph-api/reference/v2.2/payment ) is an example of doing it in PHP:
$request = new FacebookRequest(
$session,
'GET',
'/{payment-id}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
It returns NULL. They say later that:
An app access token for the app that created the payment is required.
I have no idea how to get one and then how to send it along with the above request.
Can somebody help?
You need to make the following get request:
https://graph.facebook.com/oauth/access_token?client_id={app_id}&client_secret={app_secret}&grant_type=client_credentials

Facebook API get all my Status

Hi guys i've searched a lot here on stackoverflow but i'have not find a solution for my problem.
I'm building a (University) project , this project aims to do some operation (like sentiment analysis) on a user statuses.
I'm using Facebook PHP SDK , and after login i can get some of my Statuses with this code :
$request = new FacebookRequest(
$session,
'GET',
'/me/statuses'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
var_dump($graphObject);
Now the problem is that with this code, i get something like ~20 of my statuses, and at the very bottom of the response i got the paging links (previous or next) for get ~20 more statuses.
There is a way to get all my posts from the first? Or some trick to get that?
Thanks in Advance Nico.

Getting list of events from a Facebook Page

So I have a friend who is a musician and has a page set up. He has asked me if there is a way of getting all the events on his Facebook Page via the Graph API and then putting them onto his website. I said I'd look into if this is even possible given that the API is now at version 2 and the PHP SDK has been bumped up to version 4.
Does anyone know how I'd do this? I already know how to make 'GET' request using the new PHP SDK, however I don't seem to be able to get the necessary fields.
Any help would be great!
Thanks!
It's given on developers.facebook.com
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/{page-id}/events'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
More at https://developers.facebook.com/docs/graph-api/reference/v2.0/page/events
Hope this Helps.

Categories