Asked  10 Months ago    Answers:  5   Viewed   4 times

I can retrieve facebook cover source and offset_y from graph api for example -

https://graph.facebook.com/Inna

I get this -

"cover": {
      "cover_id": "10151356812150381",
      "source": "http://sphotos.xx.fbcdn.net/hphotos-snc7/s720x720/419277_10151356812150381_302056140380_23114100_97822830_n.jpg",
      "offset_y": 54
   }

But when i look at the actual facebook page for this, i see the top offset is -135px. How is that calculated from 54?

I want to display someones cover photo on my website, with the same offset as facebook. So I am basically doing -

<div class="ed-cover">
            <img src=""/>
    </div>

CSS -

.ed .ed-cover
{
    height:315px;
    overflow:hidden;
    position:relative;
}

.ed .ed-cover img
{
    width:100%;
    position:absolute;    
}

JS -

FB.api(artist, function (data) {
                        $('.ed-cover img').attr('src', data.cover.source).css("top", -1 * data.cover.offset_y);
                    });

But the CSS offset here for the "top" property is incorrect as i get back 54 and the real offset is -135px;

 Answers

1

Yes i actually found the answer myself. The offset that facebook sends is in percentage!

The following worked perfectly -

    FB.api(artist, function (data) {
                            $('.ed-cover img').attr('src', data.cover.source)
.css("top", (-1 * data.cover.offset_y) + '%');
                        });
Wednesday, August 4, 2021
 
HMK
 
HMK
2

You need to retrieve all the albums and then get all the photos. This can be easily done by using FQL:

SELECT pid,owner,src_small,src_big 
FROM photo 
WHERE aid IN (
    SELECT aid 
    FROM album 
    WHERE owner = your_page_id
)

EDIT:
Also you need to query the stream table to get the wall posts then check if you have attachments and the type of the attachment:

SELECT attachment
FROM stream 
WHERE source_id = 116860675007039

Result:

[
  {
    "attachment": {
      "media": [
        {
          "href": "http://www.facebook.com/photo.php?fbid=1801693052786&set=o.116860675007039",
          "alt": "test",
          "type": "photo",
          "src": "http://photos-f.ak.fbcdn.net/hphotos-ak-snc6/185861_1801693052786_1553635161_1863491_4978966_s.jpg",
          "photo": {
            "aid": "6672812206410774346",
            "pid": "6672812206412558147",
            "fbid": 1801693052786,
            "owner": 1553635161,
            "index": 11,
            "width": 246,
            "height": 198
          }
        }
      ],
      "name": "",
      "caption": "",
      "description": "",
      "properties": [],
      "icon": "http://b.static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
      "fb_object_type": "photo",
      "fb_object_id": "6672812206412558147"
    }
  },
  {
    "attachment": {
      "description": ""
    }
  },
...etc
]
Thursday, April 1, 2021
1

I've worked around this by providing a login link on the page using the php-SDK getLoginUrl() and having the users use that instead of doing a client-side call to the javascript login() function or using the facebook social/login plugin. It might run into drawbacks at some point, but for now this seems to work on machine(s) that have 3rd party-cookies disabled

Thursday, April 1, 2021
 
Valdas
 
1

Making a POST request to https://graph.facebook.com/PAGE_ID/tabs is outdated – you need to use /PAGE_ID/subscribed_apps now to subscribe to updates from a page.

https://developers.facebook.com/docs/graph-api/reference/page/subscribed_apps/

Thursday, April 1, 2021
 
SJain
 
3

You'll need a Facebook app and to grant that app the ads_read permission in order to retrieve reports about your advertising efforts via the API (source).

You'll want a long-lived token so that you don't have to re-authenticate very often. The access token documentation details the steps to exchange a short-lived token for a long-lived one.

You may also want to consider managing the app, ad account, and access tokens (via a business system user) with the FB Business Manager.

Friday, October 1, 2021
 
icehawk
 
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share