How to Post to a specif users wall - using graph API - facebook

I have successfully posted a message to my own feed (logged in users).. now am trying to post to a specif friends wall... but no luck so far..
I tried putting the parameter "to" with the target users ID but the post is still happening in my news feed and can see by all others..
Please help
Anz

It's all in the documentation
Most write operations require extended
permissions for the active user. See
the authentication guide for details
on how you can request extended
permissions from the user during the
authentication step.
/PROFILE_ID/feed write to the given profile's feed/wall

Related

Facebook API for Share returning empty results set

I am new to Facebook API. I am building a Facebook app to fetch all the name of people who shared, commented and liked a post in a tabular format. I am able to get the like and comment details through Facebook API but can not find and proper API to get the share details.
I am using
https://graph.facebook.com/post_id?fields=sharedposts&access_token=my_access_token.
This API is returning an empty result set. And I have granted all the available permission to the access_tokn. Can anyone tell me ,Is there any other API that I can use. I saw a option of scraping the Facebook page for share,but I don't want to go that way because Facebook keeps on updating every thing.
I'm having the same problem as you, but I think I'm going a little step forward.
Try adding a limit to your sharedposts and maybe it will return some data:
Try this way:
https://graph.facebook.com/post_id/sharedposts?access_token=my_access_token&limit=1000
That should work for a regular post.
EDIT: Maybe the problem could be that althought you have granted all the perms to the token, the people who share that posts have to accept that permission too.
Otherway your JSON won't return any data.
The /sharedposts endpoint will -only- retrieve posts from users who have -also- granted your app. This means that even though a post might be public on a users' timeline, unless they have also granted your app permissions, you will not be able to retrieve that post.
For example: a user posted to a page and the post is public. This post can be retrieved with an access token. Let's assume that the user also shared this post to their own timeline. But, since the user has not granted permissions to your app, you will not be able to see this post using the /sharedposts edge on the original post (on the page). This also holds if the user shared their post publicly to his timeline.
This behaviour is by design; the API is more restrictive in returning user data than the website is. This holds for multiple endpoint and this is one of the examples where it is the case.
Source: https://developers.facebook.com/bugs/1404733043148335

Unable to Receive Wall Posts after OAuth

First off, I am new to using Facebook's Graph interface but I've read the documentation and am still unable to retrieve the desired result. First I was able to set up an app account and retrieved my App ID and App Secret, I then set up and advance OAuth Dialog that will ask the user for read_stream permissions (accessing the news feed). I have successfully had three users go throught the authenticator and it allows me to see more of their data but still no wall post (which I assume is the news feed). Below are the steps I followed if someone can help. Thanks. (Sidenote - All urls below came straight from the facebook documentation.)
https://www.facebook.com/dialog/oauth?client_id=XXXXXXX&redirect_uri=http://myurl.com/wheredataisdisplayed&scope=read_stream&state=SomethingIndentifiable
returned: state and code=1XXXXXXXX, I then used that to get the OAuth Token
https://graph.facebook.com/oauth/access_token?client_id=XXXXXXX&redirect_uri=http://myurl.com/wheredataisdisplayed&client_secret=XXXXXXXXXXXXXXXXXXXX&code=1XXXXXXXX
returned access_token = XXXXXXXXXXXXXXXXX and expires = 9875067805, I then tried to query the data for that user
https://graph.facebook.com/me?access_token=XXXXXXXXXXXXXXXXX
The end result is more data than what is publicly available but I still don't have access to the users wall data. Another thing I want to do with this is to use it with an infinite session key so that once the user does this once they will have continued access to their data but that I can work out later, Thanks for any help in advance.
Are you accessing /me/feed correctly, and if so are you receiving an error message when you do so, or just nothing back?
/me/feed should work for this.
You can also request /me/permissions to check if the correct permissions were granted which may help you solve the issue

Post on a company facebook page wall on behalf of a user

I have a wp7 app that connect with facebook and lets assume i have the users access token
I am wondering if it is possible to write on the wall of some company facebook page as the user. (i have no ownership of the facebook page and not affiliated with it in any way)
If it is, do you know which permission do i need to obtain ? would love to get any kind of code snippet or a direction i should follow.
Thanks.
it's not possible to write on the wall on behave of the user. You always get a token in the context of a Facebook application - so it will be the app posting on the wall, not the user. And the maximum permission app can ask a user for is publish_stream which allows you (your app actually) to:
Enables your app to post content, comments, and likes to a user's
stream and to the streams of the user's friends.
so in order to post to the company wall, you need to:
Request publish_stream permission from the user
Issue a post request to https://graph.facebook.com/<>/feed url with your message
It's really easy to test. Go to https://developers.facebook.com/tools/explorer, click on "Get access token", select "publish_stream" permission in "Extended" tab, set action to POST, enter "LGUSA/feed" into URL field, click on "Add a field", enter "message: test" and click POST. You will get ID of your post back. See screenshot attached
Sorry this is going to be a bit vauge, but here goes:
First the user is going to have to be authenticated to facebook. There is a good example here. This will give you an authentication tolken to allow you to interact with the API.
The user is going to need facebook permissions to write to the wall. Facebook permissions are described here. I don't know about the specifics of your problem, but with more details I may be able to help more.
then you shoud be able to post to the appropiate wall using the facebook graph api (you'll probably need to be signed up to facebook with a developer account to get to this page).

Can I post a comment on a status programmatically?

I've been reading up on the new documentation, and I've found out how to post a status as a user, and how to read a status and all it's comments, but I haven't found a way yet to post a comment. My goal is to have the backend of my application mirror exactly the interaction on Facebook, such that if a user (whose access token we have) comments on a post in our iOS app's custom UI, our server can update the mirrored post on Facebook by adding the comment as that user. It's sounds like it's possible from what I've read, but I can't figure out exactly how to do it from the documentation. Can someone explain more clearly how to post comments, and what access privileges I need to do so?
You need to have publish_stream permissions from the user and then you just issue an HTTP POST to https://graph.facebook.com/postID/comments?access_token=... with a "message" post parameter equal to the comment you want to post. Its documented here under the section titled "comments".

How do I post a link to the feed of a page via the Facebook Graph API *as* the page?

I'm working on a plugin for a Wordpress blog that posts a link to every article published to a Facebook Page associated with the blog.
I'm using the Graph API and I have authenticated myself, for the time being, via OAuth.
I can successfully post a message to the page using curl via a POST request to https://graph.facebook.com/mypageid/feed with e.g. message = "This is a test" and it published the message.
The problem is that the message is "from" my user account. I'm an admin on this test page, and when I go to Facebook and post an update from the web, the link comes "from" my page. That's how I'd like this to be set up, because it looks silly if all the shared links are coming from a user account.
Is there a way to authenticate myself as a page? Or is there an alternate way to POST to a page feed that doesn't end up being interpreted as a comment from a user?
Thanks for any thoughts or suggestions.
To post as the Page, you need to get an access token for the page by getting an access token for an admin of the Page with the "manage_pages" and "publish_stream" permissions. Then, using that access token, hit https://graph.facebook.com/me/accounts?access_token=THE_ACCESS_TOKEN. You'll get a JSON output of all the Pages that user admins and in there you'll see an access token for each Page. If you use one of those access tokens to POST your message, you will be doing so as the Page. The process is outlined in the documentation here (sorry, it's kind of buried).
Ah, it's a bug.
you need to use enable_profile_selector
http://developers.facebook.com/docs/reference/javascript/FB.login
Please have a look at the comments by "Nam Thai" on this thread: http://www.takwing.idv.hk/tech/fb_dev/faq/graphapi/graph_27.html. This solved the problem for me.