I have an app and I want to post to the users feed.
All the users have allowed publish_stream permission but I have no idea how to post to their feeds which I should be able to do even if the user is offline.
I want to use curl and the graph like this:
curl -F 'access_token=...' \
-F 'message=Hello, Arjun. I like this new API.' \
https://graph.facebook.com/arjun/feed
Do I simply use the access code I got when the users initially allowed me access, or do I have to get a new access code each time I want to post to their feed, if so, how do I do that?
Any help, much appreciated.
After the user authorized your application you get an access-token from facebook. You can use this token to post to the users-wall until he changes his password or removes your application from his application list.
I think you need to include your api-key in the request. Otherwise please provide the error message your getting!
Related
I'm trying to create a test page on Facebook while developing an app. Per the instructions, I've created a test user, noted the user id and created an access token.
I'm now trying to make a POST request via curl to create a page
curl -i -X POST https://graph.facebook.com/v3.3/{user-id}/accounts?category_enum=MARKETING_AGENCY&name=Test%20Page&access_token={access-token}
However the response is an error
(#100) The parameter name is required
Seems I have supplied the name parameter though; any ideas?
EDIT
If I remove the category_enum param, the error becomes
(#283) Requires manage_pages permission to manage the object
However, I have verified the user has the manage_pages permission....
Beware of the facebook api documentation... On the surface it looks like only the name parameter is required, however after hours of experimentation with the Graph API Explorer I managed to create the test page with no less than 9 required parameters!
I have an application which use rest-framework for communication between client (javascript mvc) and server(django) and I want that this communication will be allowed only for logged users and my users will be able to register via my custom registration and also to login via google or facebook or anythong else.
I am able to complete OAuth2 flow and now I have access token from google/fb and profile info.
But I am really really confused what to do next, of course I can create user instance, but I dont now where to store access token, or if thats even necessary.
Whats recommended approach? Should I use access token for accessing my APIs like this?
curl -H "Authorization: Bearer <your-access-token>" http://localhost:8000/api/...
or should I login new user, create new session for him, which then I send to client and use sessionAuthentication? Or anything completly else?
I cant find any example of doing this :(
I checked OAuth2 part of rest framework doc http://www.django-rest-framework.org/api-guide/authentication#oauth2authentication but It looks like mentioned django-oauth2-provider is only for creating my own OAuth2 system.
Im sorry if it sounds like stupid question, but I really appreciate any advice.
I've tried do develop automatic code that would fetch data from ads campaigns under account. My plan is to have server that would query every day to get data from impressions/clicks/costs of ads and save it for later use.
I use https://developers.facebook.com/tools/explorer to get access_token for getting data (insights) from those campaign pages but when I log out to try offline_access it tells access_token is old, cause of password change or access_token getting outdated.
Isn't the whole point of offline_access to grant acccess when user is not logged in?
And besides that.. what's with most of my calls ending having reply as follows:
"(#294) Managing advertisements requires the extended permission ads_management, and a participating API key"
I've given access_token that has ads_management, but I have no idea what this Participating Api key even means. Do I need to add this to url call or something? Where do I get this Api Key?
Edit: I want to be able to get data from add campaign pages, so I'm not talking about Apps in page
You will want to read up on the deprecation of the offline_access here: https://developers.facebook.com/docs/offline-access-deprecation/
But most importantly follow the guide here on how to handle invalid access tokens:
https://developers.facebook.com/blog/post/500/
You app is to monitor the error messages coming back from the API and handle it gracefully.
I have the same issue and I found this bug can be reason of our problem. It's already accepted and assigned, but still not solved. I hope it's really bug and not a secure hole, that was closed :)
We have an application that allows to users publish content to their friends wall.
It uses the user's access_token given our application.
It works stable usually, but for some reason for one of our clients it doesn't work at all.
We've checked permissions several times, removed-added them again, but still no result.
There is no error message or something, everything looks fine, complete the action, but no posts published in fact. And it doesn't work only for one person.
What possibly can be a problem?
Updated: The problem is actually in this OAuthException:
Error validating access token: Session does not match current stored
session. This may be because the user changed the password since the
time the session was created or Facebook has changed the session for
security reasons.
We tried to get access token one more time, but that didn't help. Somebody familiar with this issue?
your user might forbid people/applications to post on his wall.
"There is no error message or something, everything looks fine, complete the action, but no posts published in fact."
Are you sure about this? You should be getting back a unique stream id of the feed item just posted.
Facebook frequently changes its policies that sucks!
Now, you need permission to access the wall.
You need to check if the user has permission to access your application / wall page. if user hasn't got permission then you need to ask for permission before message is streamed. Yes, that's true, it won't display any error message, unless you manually debug this to see where it is stopping.
My suggestion is:
1. use FB.login method to verify, if the user is not logged in then he should login
2. verify the user permission for the wall page
FB.api('/id', function(response){});
3. publish / stream the comments on wall
FB.api("/id/feed", 'post', { ... blah blah blah !
edits:
At FB.login method, you should ask for permisions
e.g. FB.login(function(response) {..} ... ,{scope: 'offline_access,publish_stream'});
I've done extensive research on this, and am baffled. Similar questions on stackoverflow have been answered with, in in short: RTFM. Well, I've done that, and more, and I still can't find how to do this.
On the main FB Graph API page, documentation is given for authenticating, reading, publishing (creating), deleting Graph objects, but I don't see modifying anywhere.
The FB Graph API > User page gives description only of how to create and delete an event on behalf of an authenticated user. I've had no problem with these two actions.
The FB Graph API > Event tells you how to retrieve an existing event, as well as publish to the existing event, posts, links, feed, etc. Once again, no help with modifying.
I've tried (desperately) (':'s removed intentionally due to hyperlink limit):
Sending the same POST request as creating event, ie to https//graph.facebook.com/<user_id>/events, but with an extra 'id' parameter--the existing facebook event id. Facebook doesn't like that, gives me an 'id parameter already sent' error (I'm assuming the user's id).
POSTing to the event directly ie to https//graph.facebook.com/<fb_event_id>/ using the same auth_token as was used to create it. 'Post unsupported' error message.
The fields I send along with the POST are the same as those when creating the event-- 'name', 'location' etc.
If someone's been able to do this, one simple POST example would clear everything up for me.
Thanks!
UPDATE I started using the PHP SDK, but lack of examples disheartening. In hopes that this will save someone else frustration Here are doc examples augmented with an actual api call example:
"You can create an event for a user by issuing an HTTP POST request to
PROFILE_ID/events with the create_event permissions and the following
parameters."
$facebook->api('/'.$profile_id.'/events', 'POST', $params);
Normal enough ... but edit event docs (as of 12/7/12) are misleading:
"You can edit an event by issuing an HTTP POST to /EVENT_ID with the
create_event permission. "
$facebook->api('/events/'.$eventid, 'POST', $params);
Brian
I was able to update a page event by using a POST (not a PUT) directly to the event, using the account or page authentication token. It sounds exactly like what you did in 2 above.
curl -F 'access_token=...' \
-F 'name=A modified event name.' \
https://graph.facebook.com/event_id
I would suggest that you try just sending a modified name field. Also, because you have already created the event, you have the correct permissions. For those who don't know, you need the extended permissions of offline_access, create_event, manage_pages, etc.
It is frustrating, because at one time there was documentation on updates on the Facebook site, but now I can't find it.
Updating is the same as creating BUT, you can only update events created by your APP ID..