Facebook Graph API - Get user feed posts with pictures - javascript

I'm using the Javascript SDK, and I'm currently able to successfully have a user log into my app using their Facebook and get posts using /me/feed. However, those posts only seem to have the fields: message, story, created_time, and id. How can I get the pictures, links etc associated with these posts?
Thanks!

You have to ask for the Post fields you want to get:
/me/feed?fields=message,xxx,...

Related

Share HTML form data between two different webpages

I want two webpages in my website in such a way that:
Users can input their data into some textfill/textarea (html form) in webpage-1.
Their data is shown in webpage-2.
**webpage-1:(user page)**
post :
name:....
age:....
roll:...
description:......
**webpage-2:(admin page)**
post no:1
name:....
age:....
roll:...
description:..........
post no:2
name:....
age:....
roll:...
description:..........
post no:3
name:...
age:....
roll:...
description:..........
The basic architecture of your website should be something like this. Design both pages and share the data using local storage.
Follow these steps:
Design your User page. Add a form to using which the user can input data related to the post. Use setItem() method of localStorage web api to store posts in an array.
var posts = [];
localStorage.setItem("posts", JSON.stringify(posts));
Design the admin panel where you have to show the data. Fetch the posts array from local storage using getItem() method.
var storedPosts = JSON.parse(localStorage.getItem("posts"));
The data is stored in browser's permanent memory. This way you won't lose your posts data while moving from User page to Admin page.
Read this article for a detailed explanation of localStorage along with examples and projects.

How to import my own private facebook photos to my website?

I searched internet for hours and I couldn't figure out a simple way to do this ...
My goal is to let everyone who access my website see all my own facebook photos (so I will be using my own user id , not the logged in user) . I don't like to use Embedded Posts because I want photos to be synced with my own personal facebook photos every time a user refreshes the page...
So do I need to give my facebook app full permission to access my own profile so it can retrieve all my data without asking for login ?
one more thing , I'm really confused about where facebook permissions are stored in ? and how they work ?
You would need to use the Graph API to read the photos, this is the API call: https://developers.facebook.com/docs/graph-api/reference/v2.3/user/photos#Reading
You need a User Token for that, an Extended User Token is valid for 60 days and you need to refresh it manually every 2 months.
More information about Access Tokens and how to generate them:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/

Facebook API profile picture

I created a website for my Students Organization.
On that website there is a page where I list all the people who helped organize our Activities. Theres a picture of every member there.
To get the images, I used their facebook profile pictures.
I used http://graph.facebook.com/USERNAME/picture?height=250&width=250
This code did work a few days ago, but now the images dont seem to load. I followed the url and got a JSON object:
{
"error": {
"message": "(#803) Cannot query users by their username (user.name)",
"type": "OAuthException",
"code": 803
}
}
So it seems to me that facebook might have changed their security... (after googling I found out about some changes in their API 2.0 but I didnt fully understand that..)
This link does still seem to work if you have the userID, but I'm unable to get that userID because of the same error message through graph.facebook.com...
Is there still a way to get facebook profile pictures of people on your website or did facebook totally block this off??
Any help is appreciated!
If you want to use the data, you'll need to implement Facebook Login for your website, where the users can give their permissions to your app to use their data.
The username field is no longer accessible with the Graph API v2.0. There are at least 5-10 questions on this on StackOverflow today.
Look at the docs:
https://developers.facebook.com/docs/apps/changelog#v2_0

Is it possible with facebook-php-sdk to post to a user's wall without leaving "via" in the status update?

[My Goal:]
I want to provide users with a facebook login button on my site with a FORM for them to fill out
that will post status updates to their wall from my site so they don't have to leave my site to goto facebook.
[The Situation:]
I'm using the facebook php Software development kit found here:
https://github.com/facebook/facebook-php-sdk
The examples/with_js_sdk.php demo script works for displaying the user's account information.
I have edited it so it posts a new status update to the user's wall with "testing this api' by making the following changes to the script:
$user_profile = $facebook->api('/me');
$facebook->api(
array(
'method' => 'users.setStatus'
, 'status' => 'testing this api'
, 'uid' => $user_profile['id']
)
);
The login button reads:
[My Issue:]
The issue I have with the above is that, unlike a user actually posting to their wall manually, posting via the api includes a link to the api that posted it.
Thus their post on facebook would look like:
is testing this api
4 seconds ago via MyAPINameWithALinkToThePageIDontWantPeopleToKnow
I don't want the API to include the "via" part in the user's status update on their wall.
[My Question:]
Is what I want, as far as leaving out the "via" part in the user's post, possible through the facebook api?
[What I've Tried:]
I've tried looking through the facebook api documentation.
I've tried googling this question and found similar questions:
https://stackoverflow.com/questions/12756777/remove-app-name-in-app-post-feed-using-facebook-javascript-sdk
http://www.vbforums.com/showthread.php?658541-Facebook-omit-quot-via-app-name-quot-from-Wall-posts
Seems to be hopeless...
then I found that this isn't possible via feed dialog. So I used Open Graph actions to accomplish this.
Use this for making your app smart :)

Facebook Request Dialog for single person

I am making a simple turn based board game on facebook. I plan to make a multiplayer mode where two player can play together like a duel mode. To do that, a person can send an app request to another person using facebook request dialog. But the user can select more that one person in that dialog. How do I make it send the request to only one person?
I could send to only one person using the graph API. But then, I need to get the target person's facebook id. I couldnt just 'prompt("Give me the user's facebook id")' for it. What the user need is a dialog where the user can select one of his friends, and return the facebook id. Is there such dialog in facebook? Or I will just need to make one.
You need to make one yourself.
Retrieve all friends through Graph API or FQL
Let the user choose one of them
Fire the Request Dialog with that specific friend's ID
i had the same question and landed here. I know that this is a old question but still people can and will find this.
So the right answer for me is:
FB.ui({method: 'apprequests',
message: 'My Great Request',
max_recipients : 1
}, requestCallback);
You can find this information at https://developers.facebook.com/docs/reference/dialogs/requests/
I hope I could help some developers
cheers.

Categories