Getting images from FB posts to my website

84 Views Asked by At

I have prepared a FB feed to my website using graph API. I have this code:

require 'Facebook/autoload.php';

$fb = new Facebook\Facebook([
    'app_id' => 'xxx',
    'app_secret' => 'xxx',
    'default_graph_version' => 'v2.10'
]);

$access_token = 'xxx';
$fb->get('xxx?fields=id,posts,photos', $access_token);

The result is

Facebook\FacebookResponse Object
(
    [httpStatusCode:protected] => 200
    [headers:protected] => Array
        (
            ...
        )

    [body:protected] => {...}
    [decodedBody:protected] => Array
        (
            [id] => xxx
            [posts] => Array
                (
                    [data] => Array
                        (
                            [0] => Array
                                (
                                    [created_time] => 2017-10-24T08:31:36+0000
                                    [message] => ...
                                    [id] => XXX_YYY
                                )

                            [1] => Array
                                (
                                    [created_time] => 2017-10-23T19:31:16+0000
                                    [message] => ...
                                    [id] => XXX_YYY
                                )

                            [2]=> Array ...

Each post has own ID in format 'XXX_YYY'. When I go to facebook.com/XXX_YYY, I see the post detail including images which were added to this post (one or more). In returned values above the images are ignored.

In Graph API Reference there is no option how to add images to this feed. Possible values are just 'photos' - images in Galleries, and 'picture' - FB page picture. No chance to get images which were added directly to post...

Any idea, how to add the 'images which were put directly into post' into my feed?

Thanks.

0

There are 0 best solutions below