Update facebook status from site - facebook

In my site page one text box and publish button.
When i clicked on button which is a text in text box its published on facebook as status.
For this update status user have to allow this application on facebook.
Once user allow this application whenever user clicked publish that text will update status of facebook.
and also user need not to login agian and agian to facebook. Its done internally
like update facebook status from twitter.
I am new in php.
is there any easy solution?

If somebody is looking for a working script: You can also use:
http://360percents.com/posts/php-curl-status-update-working-example/

If you only want to update the user status information you don't need to create a Facebook application. You can do it with PHP Curl library. Look at the example here - http://codesnippets.joyent.com/posts/show/1204

There is this class http://www.barattalo.it/mini-bots-php-class/ that allows you also to post on a fan page wall with a small bot, without using the facebook API.

Since the offline_access permission has been removed recently (read about that here), you'll need to get a long-lived access_token. This will let you do status updates for your users on behalf of your applications for 60 days. After 60 days, you'll have to get your users to authenticate again, since your access token would be invalidated.
You can read about that here:
https://developers.facebook.com/roadmap/offline-access-removal/

Related

Do review required if we want to get Facebook Page like count (Without Facebook login) by Facebook app token?

I am doing a static web page in my website, in which I am showing the like count of particular Facebook page. There is no kind of login required to see this web page. Also, I don't want to user to login with their Facebook account to see the Facebook page like count.
I have implemented this requirement by using Facebook app token.
API: "https://graph.facebook.com/PAGE_ID?access_token=APP_TOKEN"
But the problem here is, If I use the app token of already approved app by Facebook with some permissions (manage_pages) exists, it works. It is not working for the app token of newly created Facebook app.
I have sent the app for review to Facebook by requesting manage_pages permission, but they rejected the app and said that my website doesn't have the Facebook login functionality implemented.
Since it is not documented clearly, I have a doubt that do the app need to send for review if I want to get the Facebook page like count without Facebook login (By using Facebook app token)? If yes, what permission do I want to request?
Any help would be much appreciated.
First of all, you need to learn what Tokens there are:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
For your problem, you can just use an App Access Token. There is no need for any permission or Login Review, the links above tell you exactly how to create one. Make sure you never use the Token on the client, especially because it includes the App Secret. Do the API call on the server only (file_get_contents or curl, if you use PHP).
If by "it does not work" you mean that you only get the id and the name, then it´s not about "not working", you need to read the changelog and search for "Declarative Fields": https://developers.facebook.com/docs/apps/changelog#v2_4
So if you want to get more than just id and name, the API call would be like this: https://graph.facebook.com/936299239766048?access_token=YOURAPPTOKEN&fields=id,name,likes,...

how to request permission to post ads on a page as an app?

I'm working on a facebook app that posts newsfeed ads, and I have been banging my head against the wall for the last few days, the work flow should go like this:
User provides his page id.
The App requests authorization to post ads on the page. stuck here
App verifies that the user authorized it.
App creates adcreatives using the user's page_id in the object_story_spec call to /adcreative using the app's ad account.
I went through How to post to page as an app?'s docs, couldn't figure it out.
the app is written in Go, however if you can provide a code sample it doesn't matter what language you use, I just need the basic work flow.
Not sure what you want to do exactly, but if you want to create ads (for am ad_account/user) via an app, you'll need the ads_management permission during Facebook Login.
How you manually create a login flow can be found in the docs as well.
See
https://developers.facebook.com/docs/facebook-login/permissions#reference-extended
https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

Permissions needed to upload photo for a Facebook app

There seems to have been a huge change in the way Facebook manages apps that access their API. Now it seems if you want to create any app that allows uploads to Facebook this application MUST be reviewed by Facebook. Am I wrong? has anyone actually managed to speak or correspond DIRECTLY with anyone at facebook to confirm this?
So my question is, after a week of hair pulling and trying to get a simple image uploading application working, what permissions are necessary to upload a photo to facebook?
Right now I have
publish_actions
email
pubic_profile
user_friends
I'm guessing I ALSO need user_photo permissions.
But the convoluted process that is required to add more permissions has me stumped.
First i click new submission. Then I select user_photos. But I then get an error saying 'It looks like you haven't made any API requests to access content with the user_photos permission in the last 30 days. You need to test this permission in your app with any account listed in Roles before you can submit for review. It looks like you havent tested this permission because no API request has been made against publish_actions in the last 30 days.
Which seems INCORRECT to me since in my signed GET request for image uploading I see the following
redirect_uri fbconnect://success
display touch
state {"is_open_session":true,"is_active_session":true,"com.facebook.sdk_client_state":true,"3_method":"fallback_auth","0_auth_logger_id":"foo"}
scope ****user_photos****
Ok, can any Facebook API experts confirm that
1) I definitely need to submit my app for review in order to upload photos to a facebook account
2) I need user_photo permissions
and
3) I must first set up a test user and test with user_photos BEFORE I submit the app
Addendum. After further testing am getting the image upload to work for all users, BUT only after logging in a 2nd time. ie after first login submit the user is presented with a new blank login popup. Only after logging in a 2nd time (the photo upload is done immediately after login) is the image uploaded successfully.
Can anyone suggest why this is happening? I've posted a 2nd question here
Facebook Image Uploads-required to login twice for first upload
do this and you problem will solve
go https://developers.facebook.com/tools/explorer/
select your Application and get access token and put this in field of submit "me/photos?fields=album" and press on submit >
that is done . that requests API to access content with the user_photos permission ..
Also can do that for every permission need to API requests just with some chage ...etc
It should be clear from the docs what is necessary and what not. I think I already answered questions 1) and 2) in your other question:
Latest Facebook Graph API > only admin user can login-upload photos
I doubt that 3) is necessary, because according to the docs user_photos is needed to retrieve photos, and publish_actions to upload photos...
References:
https://developers.facebook.com/docs/graph-api/reference/user/photos/#Reading
https://developers.facebook.com/docs/graph-api/reference/user/photos/#Creating

Facebook connect and account remove

I have a website where users can log in with the Facebook oAuth API.
Once the user logs in or registers via Facebook it is stored in my database.
But what I'd like to achieve is, once the user goes to his Facebook application settings page and removes my website app permissions, the used should also be deleted from my database.
Is there any work around to this problem, if this is not possible via the Facebook oAuth API?
You can add Deauthorise Callback URL by Navigating to Settings > Advanced section of your application. Whenever a User Deauthorises your Facebook app, Facebook performs a HTTP POST of signed request to your URL. You may use the field user_id to determine which User has deauthorised your app.
Actually, I would do the following:
Add a date to his last log in to your site.
Have cron job check for old, unused accounts.
Send an email to the user's email address (or Facebook message mail) telling him his account is due to expire soon.
Delete account from database.

Auto post with facebook

I'm using facebook login (with facebook api) for one of my web application .
After user logged with their FB account I'm assigning secret unique code for the user in my application side .
So now I need to login to the particular user FB account automatically and post pre-defined message on that user wall when user enter that unique code (Actually users are using RFID tags sometimes they will enter that code manually)
So Is it possible to do that automatic login to the FB ?
Sounds a bit fishy ....
still:
https://developers.facebook.com/roadmap/offline-access-removal/
you can extend a users token for 60 days ...
cheers