I'm grabbing Facebook Post's pictures via Graph API call:
GET /mypageid/posts?fields=id,created_time,picture
Here's a sample response:
{
"data": [
{
"id": "1389378987988776_1745791089014229",
"created_time": "2016-08-03T21:55:39+0000",
"picture": "https://external.xx.fbcdn.net/safe_image.php?d=AQBQL02u4kJtLNFs&w=130&h=130&url=fbstaging%3A%2F%2Fgraph.facebook.com%2Fstaging_resources%2FMDExNzQ1NzkwNjg5MDE0MjY5Ojk5ODEyOTY4Ng%3D%3D&cfs=1"
},
{
"id": "1389378987988776_1745301615729843",
"created_time": "2016-08-02T18:10:53+0000",
"picture": "https://external.xx.fbcdn.net/safe_image.php?d=AQD7O17OAki29Gus&w=130&h=130&url=http%3A%2F%2Fcdn2.obsnocookie.com%2Fwp-content%2Fuploads%2F2015%2F03%2F13995025_770x433_acf_cropped.jpg&cfs=1"
}
}
Does the picture URL have an expiration date?
There is no specific expiration date afaik, but you should never rely on CDN links being available later according to Facebook. If you need them, you can download and store them on your own server.
Related
I'm using facebook SDK for PHP to get post on user timeline. I use api "/me/feed" to get the timeline. The problem is that I can display text only. I want to display all image which uploaded or shared by each post.
How can I do that?
"me?fields=posts{type}" - Gives you all posts of authorized user. From that result, you'll get type attribute mentions Link, Photo, and Video. So you can filter photo only to show all user photos.
"me?fields=photos" - Gives you all photos of user's tagged(Uploaded by user friends).
"me?fields=posts{picture}" Gives you only posts with Photos.(Which you need). The return JSON format is followed.
{
"posts": {
"data": [
{
"picture": "https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-xtp1/v/t1.0-0/s130x130/14718778_1841680516118589_7768474098175322373_n.jpg?oh=6e53b43361b48c3568a72dd5b651d312&oe=588D34A5&__gda__=1486132096_8b0bef43cf74166a9b88391a7bcb9195",
"id": "319551818195811_717085918443189"
},
{
"picture": "https://fbcdn-photos-c-a.akamaihd.net/hphotos-ak-xal1/v/t1.0-0/s130x130/14724654_1745688559098754_6408885771776123938_n.png?oh=9fbab8e118743gbaf2854e60945e5dec&oe=58ABE2A0&__gda__=1486058914_4df4fb64e7b307205bbc3db4fccfc3fa",
"id": "319551818195811_717085918443189"
},
{
"picture": "https://fbcdn-photos-c-a.akamaihd.net/hphotos-ak-xal1/v/t1.0-0/s130o130/14724654_1745633559098754_6435045951276123938_n.png?oh=9fbab8e118746bbaf2854e60945e5dec&oe=58ABE2A0&__gda__=1486058914_4df4fb64e7b307205bbc3db4fccfc3fa",
"id": "319551818195811_717085918443189"
}
}
]
}
From that JSON, "Picture" is Photo URL which you posted to FB. You can embed to an image tag to show it on your website.
Note : JSON is Modified
Hope This helps :)
Can I get a specific post ID from a Webhook, currently I can make an API call and get all the data I need and store it locally to display to the user, however if I decide to use Webhbook to get new updates all they give me is a UID and ID which are both the same.
Is there any way to retrieve the specific post/notification ID through Webhook? Or does it only really tell you that you its time to make another API call and update/compare your records?
Here is an example of what I am returned -
{
"object": "user",
"entry": [
{
"uid": "123456789",
"id": "123456789",
"time": 1374846331,
"changed_fields": [
"feed"
]
}
]
}
Thanks.
As the title mentions, i wish to make a feed on a website, with the message a user posted on my facebook page and also his name and profile picture.
I managed to get the messages from my fb page but that's about all
{
"data": [
{
"message": "message",
"created_time": "time",
"id": "id"
},
{
"message": "message",
"created_time": "time",
"id": "id"
}
]
}
I have been struggling with this for some time now, is it even possible ?
You should declare the fields you want (see the doc), in your case, the from field (see post node reference).
We are building a activity stream kind of website very similar to facebook (in activity feed alone). For loading user's activity feed, we send the request to PHP file through AJAX method. Server file will handle the logic and return back the values as an array in JSON format. I wanted to know, is there any framework available to write the JSON response to HTML elements. Also, the fees are not similar. It will vary according to the type (Photo, Album, Status Updated, Shared, Liked, etc). So i need to load different template view for each of the activity feed. Actions will be common like Share, Comments for all feeds.
Can you please share which will be the best approach to load the content according to the data received. Also the content need to be refreshed periodically. I have pasted the sample JSON response below for reference:
{
"id": "1",
"picture": "",
"link": "http://www.google.com",
"name": "Srini updated status",
"description": "Lorem ipsum",
"actions": [
{
"name": "Share",
"link": "http://networkedblogs.com/hGWk3?a=share"
}
],
"type": "statusupdate",
"created_time": "2011-05-10T18:35:38+0000",
"updated_time": "2012-07-20T10:42:58+0000",
"likes": {
"count": 0
},
"comments": {
"data": [
{
"id": "19292868552_10150189643478553_22286888",
"from": {
"name": "Lorenzo Portillo",
"id": "613727863"
},
"message": "does anyone knows why i get a rhombus and '?' in my app description when I publish in a user's wall, instead of a letter with accent?!?!?!?!?!?",
"created_time": "2012-05-28T13:48:45+0000"
},
"count": 1
}
}
Need help / suggestions on how to design the template according to the json array in javascript. Any comments / code help will be more helpful.
Thanks in Advance,
Regards
Srinivasan.C
Well, if you consider making a very robust app, take a good look at emberjs.
You should also try jquery's (jquery mobile, jquery ui, jquery ajax)
You can create an html output in your php file when you are getting the response from the Facebook API. According to me you can do json operation easily in PHP. By using json_decode you get array and that you can traverse it and build an html as per your requirement.
Hope it helps
I have been playing with Facebook Graph API around a week, and I still could not find how to get user's network information? I don't know if the Graph API stores user's network; I didn't see such information. Simply, if a user is in "Google" network, may I get the name and the ID of the networks that the user belongs to?
If this is not possible, may I reach the user's secondary email addresses?
Thanks for your help.
Using FQL : the affiliations field of the User table contains this information
Sample call:
https://graph.facebook.com/fql?q=select affiliations from user where uid= 4&access_token=<ACCESS TOKEN>
Sample response:
{
"data": [
{
"affiliations": [
{
"nid": 16777217,
"name": "Harvard",
"type": "college"
},
{
"nid": 50431648,
"name": "Facebook",
"type": "work"
}
]
}
]
}