0

I am new in Drupal, I want to get all the images from my Facebook account and want to display them into front end.

I tried Facebook Album Fetcher module but this module give me the facility to get images only for a particular album not for overall. I want to get and display only the latest uploaded images from my whole account (Images will be anywhere like profile images or timeline images or album images etc).

So can anyone please tell me, is there any module which can fill my above requirement? If not then how can i get all the latest uploaded images to display them into front end?

Please help.

Thanks in advance.

2 Answers 2

0

I have resolved this in two ways.

  1. First I use Facebook FQL query to get the image of Facebook page posts image. You can find the code from here. Facebook Platform API versions after 2.0 will not support FQL. So I get the images using Facebook graph API.

  2. Then I get Facebook post images using Facebook graph API. Here is my code: Firstly you should have to get page id from where you want to get post images. From here you can get the Facebook page id.

After that use the code:

$data = file_get_contents("https://graph.facebook.com/page_id/photos/uploaded");
$results = json_decode($data);
foreach ($results as $value) {
  echo '<img src="'. $value->source .'">';
}
0

According to this answer on SO (to a 'similar' question posted 'after' this question ...), there seems to be another (better?) solution to this issue. Below is (part of) what that answer says ...

= = = Start = = =

Firstly I got the page id where all the images uploaded. To get the Facebook page id just go through the below two link:

https://graph.facebook.com/

https://graph.facebook.com/testpage.

Here is my code by which i got all the images for testpage page:

<?php 
include_once "facebook/facebook.php";
$facebook = new Facebook(array(
    'appId'     => 'YOUR_API',
    'secret'    => 'YOUR_API_SECRET',
    'cookie' => true
));
$accessToken = $facebook->getAccessToken();
$photoQuery = urlencode('SELECT pid,owner,src_small,src_big FROM photo WHERE aid IN (SELECT aid  FROM album  WHERE owner = "YOUR_PAGE_ID")');
$photoFQL = 'https://api.facebook.com/method/fql.query?query='.$photoQuery .'&access_token='.$accessToken.'&format=json';   
$photoResults = file_get_contents($photoFQL);
$photo12 = json_decode($photoResults);
foreach ($photo12 as $value) {
    echo '<img src="'. $value->src_big .'">';
}
?>

= = = Stop = = =

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.