I am trying to post to a user wall using the Graph API. I tested using my own wall, and I have authenticated my Facebook app to publish_stream.
post_params = {
access_token:FACEBOOK_APP_TOKEN,
link:'http://example.com',
picture:"http://example.com/images/logo.png",
message:"dummy",
description:'dummy'
}
get_facebook_client().client.post("#{user_fb_id}/feed", post_params)
I can successfully post something to my wall if I don't have the link parameter (containing our company url). If I include the link param, Facebook would still return the ID of the status update like {"id": "4804827_871793267189"}, like a successful post request, but post won't appear on my wall.
The above use the ruby gem rest-more, but this behavior happens when I hand code everything too.
I realize that I can post any other link (even other subdomain my company url).
So I think Facebook will ignore posting with a link which the user have shared before.
umm from looking at your code, if you add a comma at the end of link, wouldn't that fix the issue ?
Related
I'm trying to download every comment on a public facebook post (it's one of those "can you do this basic algebra problem" posts - I want to see what percent of the comments get it right).
The Graph API Reference shows that I should be able to just GET graph.facebook.com/v2.5/{object-id}/comments.
I believe the object-id of this post is {user-id}_{post-id}, where post-id is the id in the url. So given this url:
https://www.facebook.com/beth.mansfield.9/posts/10207885721596563
The user-id of facebook.com/beth.mansfield.9 is 1101752663 (from findmyfbid.com), and the post-id is 10207885721596563 (from the url), which makes the object-id="1101752663_10207885721596563".
When I try graph.facebook.com/v2.5/1101752663_10207885721596563/comments in the Graph API Explorer, though, I get:
{
"data": [
]
}
What am I doing wrong? Is there another way to get the comments? There are close to a million so loading them all in the browser and scraping with javascript would be unfeasible.
That is a user profile. You can only get data of a user profile if that specific user authorized your App. In that case, you would need to authorize with the user_posts permission. Just because it is public, does not mean you can get the data - that would only work for Pages.
I'm using Facebook Graph API v2.5 to publish and delete posts from user's profiles.
I'm using Postman (Chrome extension) to test my REST calls.
Case 1) When all actually works:
- I do a POST request to "https://graph.facebook.com/v2.5/MY_USER_ID/feed", with params "access_token" and "message"
- The API returns me the created post ID, let's say "108373569531356_138530589848987"
- Then I do a DELETE request to "https://graph.facebook.com/v2.5/108373569531356_138530589848987", with params "access_token".
- My message I successfully removed from user's profile
Case 2) My issue, it does not work as expected
- I do the same POST request as previous, but I add an extra "link" parameter.
- The API returns me the created post ID.
- Then when I try to delete this post using DELETE request, the Facebook API throws me an error: "message": "(#100) This post could not be loaded"
One thing I noticed, is that first request seems to create me a Facebook "post", but the second one seems to create a "link".
I used the v2.3 API get/post_id to compare both posts, they are pretty much different.
So, why can't I delete a "link" element, the Facebook documentation does not tell anything about it.
Many thanks !
Maybe you were suffering a bug (https://developers.facebook.com/bugs/1671530079772375/) which is fixed now.
If you published a post with a link through an app being in development mode, this post wasn't credited to your app [bug] so, if you tried to delete it, you couldn't because Facebook only allows to delete posts published by your app.
I have now tried a lot of combinations, but I fail to reproduce the same result as obtained when posting manually:
I want to post a link to a facebook page I have created (not to the user wall). I do this by obtaining the page access token:
$page_access = $facebook->api('/'.$pageid.'?fields=access_token');
Then I set (before posting):
$facebook->setAccessToken($page_access['access_token']);
Finally my post is:
$attachment = array('message' => 'this is my link',
'link' => 'http://www.facebook.com'
;
$sendMessage = $facebook->api('/'.$pageid.'/feed/','post',$attachment);
I have also tried setting the name, link and description fields in the $attachment structure, but the published result always includes a link of the type:
https://www.facebook.com/connect/uiserver.php?app_id=_my_app_id&method=permissions.request&redirect_uri=http%3A%2F%2Fwww.facebook.com%2F&response_type=code&display=async&auth_referral=1
instead of the direct link to http://www.facebook.com. However, if I post the link manually I get a direct link (this is what I want) and also a "Share" action.
So my question: How do I convince the api to publish the link as is, and also get a "Share" action?
The reason your app is not posting a direct link is because you have Authenticated Referrals enabled on your application. This means Facebook always tries to get the user to Connect to your links before they are redirected to the link.
Try disabling Authenticated Referrals and see if it makes a difference.
How to post a message on the wall of facebook or add comment to the thread using a graph api.I want a url of that.
like for adding a message to wall
https://graph.facebook.com/profile_id/feed?access_token=generated token&message=hi
But it not working ,it not get added to my wall.
You need to add &method=post to your request URL. Also, you must have the `publish_stream extended permission for your application.
https://graph.facebook.com/user_id/feed?method=post&message=hi&access_token=generatedtoken.. will work
instead of profile id give the user id
Hope this will work
I am following the Facebook developer documentation for making a post to a Facebook 'Page' as the Page itself, which according to the docs requires impersonation. I've gotten the access token for the page itself, as well as the Page's ID, by making a call to the "accounts" feed for the user who's the admin for the Page. I then POST to
https://graph.facebook.com/[Page_ID]/feed
With the post items
access_token
and
message
containing the access token and the message, and I get a JSON string back with a post ID. Which all seems to indicate that it is posting the message to the page. HOWEVER, when I go to the particular Page, it doesn't display the posted status.
Does anyone perhaps have any idea why that might be?
Thanks in advance everyone!
Did you make sure to get the "publish_stream" permission from the user?
http://developers.facebook.com/docs/authentication/permissions