I got the following exception when i try to post a message on a friends wall using the REST API
The user hasn't authorized the
application to perform this action
here is my code.
$status=$facebook->api_client->stream_publish($message,null,null,$id,$user);
How to get authorization from a user to post a message on his wall? Or any work around to do this ?
During the authentication process, you need to request the publish_stream extended permission from the user before your application is allowed to post on behalf of that user.
Assuming this is a canvas application, this page will probably help you along.
Related
when I use
$facebook->api("/userId/feed/", 'POST', $attachment);
Facebook post to my friends wall who authenticated with my application.
I don't want this.
And when I use
$facebook->api("/me/feed/", 'POST', $attachment);
Facebook post to my feed only.
so I want my APP to post $attachment array to my feed (as me) and every authenticated user feed (as him) without posting to friends wall. (sure I have stream_publish permission from authentication process)
When you authenticate the user and the user authorizes your application's permissions, Facebook provides you with an access token for that specific user. You need to persist this access token in a database (or where ever you see fit). Each time you make a request to the Facebook API, you need to pass this access token.
So, you can post as a user on their own wall by using the /me/feed endpoint, but you need to pass the user's access token along with your request. The access token is how Facebook knows who "me" is referring to.
As an example, let's say I use your application. I authorize your application with my Facebook account and Facebook gives you an access token that represents me. I use your application to post a message on my wall: "Hello World!" You then submit a request to the /me/feed/ endpoint using my access token. The message "Hello World!" will show up on my Facebook wall and shows that it was posted by me.
Do you know if there is any way to publish on my web app the facebook messages published by the users on my facebook wall application?
I'm using spring social and I tried to use the code you can see below:
facebook.feedOperations().getPosts()
With this sentence, it is launched an exception alerting that Authentication is needed.
Thanks.
Regard
Nope. If you could, then Facebook would need to seriously evaluate their security. The user needs to give you permission to access their data. After authenticating can use the returned user token to access the user's Facebook wall posts.
I want to connect my web application with the facebook business page. Each time I add a new product to the page I want to post it on facebook wall. I have a facebook application and the page owner username and password. Can I automatically authenticate with the user, pass to facebook and send the post request from server side only? Usually I am logged in with another facebook account when I add products. Also I would like to post when another page user add a product.
You can post to Facebook as a facebook page using the manage_pages permission. You'd need to obtain this permission from a user who is an administrator of the page. There are a few steps to the process, here is a basic summary:
Get an access token from a user who is an administrator of the page
and has granted "manage_pages" to your app. read about authentication
here: http://developers.facebook.com/docs/authentication/
using that access token, make a graph request to
https://graph.facebook.com/me/accounts?access_token=USER_AUTH_TOKEN
You'll get a json response containing all the pages the user administrates, containing their name, category, facebook id, and an auth token - this is what you'll need to post to that page
you can then use this access token to post to the specific page using
https://graph.facebook.com/PAGE_ID/feed?message=POST_MESSAGE&access_token=AUTH_TOKEN&method=post
I just found this blog post which gives you a pretty good explanation
http://developers.facebook.com/blog/post/465/
It sounds like you need the 'offline_access' extended permission.
It is scheduled to be deprecated. Take a look at the following link for more details:
Deprecation of Offline Access Permission
I'm not going to pretend to be an expert on this, but I do NOT recommend trying to login through Facebook's user interface and perform POST requests/HTML scraping on behalf of the user. That procedure would grant you far more functionality than is possible through the Graph API; I don't think Facebook would approve of this.
I am wondering if it is possible to post to the wall of the Facebook app page created for using Facebook in iOS. Rather than use the user login to post to their own wall, I would like to post to the app's page with updates on open games. Is this possible to do?
Yes, it's possible. From http://developers.facebook.com/docs/reference/api/application/:
To perform the following operations as an Application Page, and not the current user, you must use the Application's Page access token, not the user access token commonly used for modifying Graph API objects nor the Application access token. This access token can be retrieved by issuing an HTTP GET to /USER_ID/accounts with the manage_pages permission. This will return a list of Pages (including Application profile pages) to which the user has administrative access, along with an access_token for each Page.
…
You can create a link, post or status message by issuing an HTTP POST request to the APP_ID/feed connection. To see more details please see links, posts, and status messages documentation.
To impersonate the Application when posting to the wall (i.e. post as the Application, and not the current user), you must use an Application Page access_token with the manage_pages and publish_stream permissions, as described under Application Access Tokens above.
So you first have to ask the API for an Application Page access token and then use this access token to post on the wall. The Facebook iOS SDK helps to construct the Graph API calls mentioned in the documentation cited above.
I am having problems with the facebook authorization process within my app.
I want to post something on the users facebook page with a dialog which is shown to the user first, and request the "publish_stream" permission.
If I do so the user is redirected every 2 hours to the request page where it says that the user has already allowed this app to do this, which is very annoying for the user....
So my question is what happens if I don't ask about permission to post on the wall, but still show the user the dialog which shows what is posted on his page? is this legal ? can I get any problems what so ever by doing this?
Cause posting on the users wall without asking permission, works just fine.
thanks for the help
The Facebook documentation states that if you prompt for publish_stream, you will be able to post on the users wall indefinitely, and thus you wouldn't also need offline_access.
publish_stream Enables your app to
post content, comments, and likes to a
user's stream and to the streams of
the user's friends. With this
permission, you can publish content to
a user's feed at any time, without
requiring offline_access. However,
please note that Facebook recommends a
user-initiated sharing model.
There is no legal issues there. However users will be pi**ed off.
But when you request a token with offline_access and then use that token for publish_stream, your token will not expire.