Facebook Graph API post with attachment not showing on News Feed - facebook

I tried a number of methods of posting to Facebook using Graph API and I have a problem with creating a post with attachments not showing up in the News Feed.
If I post just a text message, it shows up in the News Feed. Anything that has an attachment goes only to the wall.
Does anyone have an idea on what is the cause of this and how to fix it?

I have no idea what was the cause of the issue, but I resolved it by creating a new Facebook App, with new ID. The same scripts that only posted to the wall started posting to the news feed on the new App ID.

I think it's because you're adding attachement or a link to your feed.
As per http://developers.facebook.com/docs/fbjs/streamPublish/
they say :
Updating a User's Status
You can use this method to simply update a user's status. When you do so, the status message appears at the top of the user's profile and on the Friends > Status Updates page. The message also appears in the stream with your application icon.
To use this method to set a user's status do the following:
* Do not include an attachment or action link. If you do, the story will get published and will appear in the stream and on the user's Wall only. It won't appear at the top of the profile or in the Status Updates page.
* Make sure the message is no longer than 420 characters. Otherwise, an error gets returned.

I know this is an old post but I was having the same issue and I resolved it. Since there wasn't a valid answer to this post and it came up in many of my searches in Google I thought I would add the answer.
The main issue that is happening here is a permissions issue with the App and Access Token created in https://developers.facebook.com.
You can both GET and POST attachements on a wall but you have to give the Users Access Token the permission to access it in the first place. You can do it like this.
1. Go to your application on FB
2. Click on Graph API Explore
3. Click on Get User Access Token
4. Click on user_photos and user_videos
There are many options here but to get the basic attachements which tend to be photos and video you can just select those two, but you can add as many as you want.
After clicking Get Access Token at the bottom to save it you have to login with your password then give your access toke permission for your account. Once you have done that you now how permission to access your feed attachements (photos and videos)
Here is what the Graph API output looks like showing the picture from the feed
Now keep this in mind this is a Short Lived Access Token which lasts about an hour and it will stop working. You have to convert this token to a permanent token and let me save you the time you will bang your head trying to figure that out because I wrote a php function that will generate your permanent token from your short lived token all in one shot for v2.9
Check out my post reply here
facebook: permanent Page Access Token?

Related

How can I detect if a certain post on a Facebook page has been deleted?

I am planning to build a small side project that stores posts from particular public pages. And detect if they delete the post later. Something similar has been done for Twitter. But I couldn't find similar projects for Facebook.
Like this: http://politwoops.sunlightfoundation.com/
But for Twitter. I will do it in Python or C#
How can I go about it?
Any particular code or projects I can learn from?
The only way to check if a post is not there anymore on Facebook is to search for it with a User Access Token of the User who posted it. Every Object on Facebook gets a specific ID, you only have to check if that ID still exists. If not, you get an Error from the API.
For example: https://developers.facebook.com/tools/explorer/?method=GET&path=10203433018378479&version=v2.0
The path parameter is the ID of the Post.
Keep in mind that you need the read_stream permission for that, and you need to let Facebook approve it for other users or it will only work for Admins/Devs of your App. It is not very likely that you will get the permission approved for this though. It usually only gets approved for Apps on "Platforms without a native Facebook experience".
Edit: My bad, i was thinking about User posts, but your question was about Pages. In that case, all you need is an App Access Token (App-ID|App-Secret). The API Call would be the same, you just need to know the Post ID.
About Access Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/
For getting the feed of a Facebook Page, see the Facebook docs (including code samples): https://developers.facebook.com/docs/graph-api/reference/v2.0/page/feed/
You can use graph api for this. If it's a public page, you can follow these steps:
Create your application in Facebook developers site
Setup the basic graph auth mechanism with your favorite language and get unexpired token.
Use your unexpired access token to do these tasks:
Enter the id of the pages you want to crawl http://graph.facebook.com/[insert page id or url here]/feed
Add post title, postID to your database.
Create a scheduled task on your server to do these tasks:
Select all / page based etc posts on your database and send a request to: http://graph.facebook.com/[insert post ID here]
if it returns it means it's still there. otherwise it will return an error.

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

Open Graph api for feed returning inconsistent results

Called the https://graph.facebook.com/{id}/feed url is randomly missing data.
Here's what I did
Create a test user for my sandbox mode app with publish_stream and read_stream permissions
Add a post to their wall via POST to graph.facebook.com/{id}/feed?access_token={token}
Login as test user and confirm post was added to their news feed
GET on graph.facebook.com/{id}/feed to view JSON data
So when I hit the feed, sometimes the successfully created Feed Post is in the JSON, and sometimes it's not. Continually hitting that API endpoint (i.e. hitting refresh over and over in my browser) will have the data pop in and out in no discernable pattern.
I have no idea what I could be doing wrong, or if it's just Facebook for that matter. What could be the problem?
I experienced this as well. My solution: Add 'user_groups' to the list of required permissions. Log out, log in again and everything should work.

How can i show the wall (feed) of my page to app on facebook?

How can i show the wall (feed) of my page to app on facebook? As i see in the page
www.facebook.com/kesha?sk=app_178091127385 and
www.facebook.com/pages/Khanduna-Yengu-Nangsu-Amuktang/187317137978077
I want show the wall(feed) of my page to my app of facebook. Please Help me.
I also try and see graph api as below
graph.facebook.com//feed
But Fail,
Please Help any one.
As I understand your question, you want to take the wall of your page and show the content of that on another page controlled by an app you have made, so that is the question I will answer.
There are a couple of things you need to do.
Facebook now requires you to have an access_token to get that information. You can get this in two different ways. Either you get your users permission to grab an access_token for them, or you create an access_token for one of the admin users with offline_access and manage_pages permissions.
There are problems with both cases:
1: Getting an access_token per user requires people to give permissions to your app which is quite annoying if they just gain access to the contents of the feed.
2: Having one access_token is also a problem seeing as Facebook puts a limit on how many requests you can make per access_token in a given time.
You need to balance these things out if you want the feed to be shown. Which case would you most likely use? If you don't have many users the second case might be the best, but if you go over the request limit no content will be shown and that could confuse your users.
Anyways.. Once you are past the access_token problem, you can access the information by getting the content from the page:
https://graph.facebook.com/YOUR_PAGE_ID/feed?access_token=YOUR_ACCESS_TOKEN.
You then get a nice json output you can use. If you are using the Javascript API you can simply use the information here:
http://developers.facebook.com/docs/reference/javascript/FB.api/
If you are ever unsure how to get the information you need there is a nice tool for that developed by Facebook called Graph API Explorer which you can find here:
http://developers.facebook.com/tools/explorer/

Editing a User's Likes on Facebook

I've been looking at the Facebook API to find some way to edit a user's Likes (that is, add or remove items from https://graph.facebook.com/me/likes/). The API doesn't say anything about it specifically, but does say this:
You can publish to the Facebook graph by issuing HTTP POST requests to the appropriate connection URLs above.
Where above, one of the connection URLs is the aforementioned https://graph.facebook.com/me/likes link. However, there's no documentation for the PROFILE_ID/likes post, and whenever I try to post it returns the error "invalid post_id".
I assume this is because to like something, you post a request to POST_ID/likes. It's a bit inconsistent. What I'm trying to do is get the user's profile to add a Page to their likes (by posting using the page's id as an "id" parameter in the post body). However, it seems like there's just no way to edit user's likes.
At the end of the day, I just want to allow a user to click a button in my application (mobile device application, not a web app) and have them add our Facebook page into their list of pages, and I've found no way of doing that short of presenting our page to them and making them click on the "Like" button manually. Many other things are supported without showing the Facebook website, like posting to their wall or making albums, but I can't find anything to do this.
Any ideas?
Looks like I can't. Not in the way I want to anyway.