How to update a user's Facebook status? - php

I looked at many similar questions here at Stackoverflow.com and searched in Google but still could not find an answer, so I am posting this new question.
I have a 3rd party PHP5 website in which users can write a short message. I want to have the ability for the user to click a button to share that message as a facebook status.
It is in my understanding that this can be done using the Facebook API and Users.setStatus. I am not sure where to begin though - do I implement Facebook connect in my site? I don't need anything but that ability, so I don't need a facebook 'canvas' page.
Do I start an application?
Could someone point me in the right direction?
Thanks!

You need to:
Create an application, paying particular attention to the Connect settings
Integrate your site with Facebook
Connect
Check the user has granted the
application the status_update
extended permission, and if not
pop up the permission dialogue
Use the Status.set API call
The details for each step are far too big for one SO answer, but hopefully that's a "point in the right direction".

You'll need to create a facebook application in order to set someone's status with Users.setStatus. You should keep in mind that users will have to install your application and allow it to publish on their behalf before you can do so, though.
Check out developer.facebook.com to get started.

Related

Posting on Facebook Page on user's behalf

A team of some friends and I have come up with an app/product idea that we have been working on. I have to be vague on exactly what the details are, but hopefully I can explain it well enough to have the questions we have answered.
First, we have a web server with a database - we have developed all of the code for that in PHP. Each user will have a device which when an action is performed on the device, it sends a message to our server, and the PHP code on our server handles the message and stores the sent data in the appropriate fields in our database.
We want to run this through Facebook - we have an app and a Facebook page created for this. The idea is that when a user performs an action on his or her device and the message is sent to the server, the PHP code will automatically make a post on the Facebook page on the user’s behalf (not on the Page’s behalf).
Between all of us on working on this project, we have spent many days and many hours trying to figure out how to make the automatic post to the page. It’s extremely difficult googling this topic since all of the various examples are using different versions of the Facebook SDK (we are using the latest). There are lots of somewhat similar type questions/examples, but we can't find one that answers specifically what we are asking. In fact, we aren’t even sure that anybody but an ‘admin’ can post on a Facebook page with the new SDK, any longer. I do see this link in the Facebook developer section, https://developers.facebook.com/docs/graph-api/reference/v2.5/page/feed, where it says under the Publishing section:
Permissions
A user access token with publish_actions permission can be used to publish new posts on behalf of that person. Posts will appear in the voice of the user.
So, it sounds as if a user can post to the Facebook page if it is given an access token with publish_actions permission, yet we can’t find any example of code of this actually being done. Could anybody explain how to do the automatic posting to the page on a user’s behalf (hopefully, using PHP, since that is the language we are using on the server side), or at least point us to a good example? We are all experienced developers, but this is the first time any of us has done anything with Facebook development. So we certainly aren’t amateurs, but with Facebook development, we are. We may be overlooking something obvious, but after seeing so many links, my mind is jello.
A summary of our questions:
1. Can it even be done with the latest Facebook SDK that a post can be made to a Facebook Page for our product on the user’s behalf? (to be clear, we are talking about the Facebook Page we created for our app, not a user's page)
2. If so, what specific permissions do we need to give the user, just the publish_actions one? We don’t want to give the user too much permission to be able to screw up our page, of course.
3. Can this be done automatically with PHP from the server?
Any help would be GREATLY appreciated!

How to create a facebook app without much knowledge of PHP/MYSQL?

I'm trying to SUGGEST, or CREATE an app, and I don't have any knowledge of facebook app creation... I've looked up on tutorials, but facebook's API might change or has changed by the date of those tutorials...
So I thought I'll ask on here, after searching for a facebook developer's support, I was redirected to here.
My question: What is the best way to create a basic app, as per my requirements (below)..?
My Suggestion/Requirements: I wrote this tutorial on superuser, which lets you display your current playing track as an updated div on your html based website. I'm trying to create a facebook app that posts these track info updates to the right side of the facebook home panel (above the chat column). Like Spotify! Or SoundCloud...
My Problem: I don't know where to start? I don't have much knowledge of scripting and according to me, it should be quite simple in PHP/MYSQL/Javascript/ ... but don't know how facebook would handle the html file from where the <div> data could be collected. I think jquery would solve that, but this can also be done via PHP/MYSQL.
It should be simple, so I'm also suggesting this as an idea for anyone willing to create this app on facebook? And if you create it, please do keep it open source project or a tutorial for it, so that if at any time you close the app, it can still be replicated. I cannot create it but am willing to, but don't know how to...
I'm asking this here because facebook doesn't appear to have a forum based posts for this apart from the developers group. I've joined the facebook developers group, but haven't yet been allowed to post anything, as the join request is pending.
That's mostly all. Thanks for any help.
Start with registering your application on Facebook .It will give you some token and keys.
Now you can follow any tutorial online to create application on fb.

How to update facebook page?

I am a PHP developer who was asked by a client to update their Facebook business page with changing statistics. Not by posting the information as status updates at an interval, but to update the Facebook page description like AJAX would update a page view counter. Is this possible? Can you point me in the right direction of how to implement this?
You're going to need to authenticate your application (this is also good reading here) and ask for extended_permissions, specifically the manage_pages permission.
This allows your application to login as a page.
Then you can modify certain parts of the page attributes.
There is a nice class available on phpclasses.org to aid in logging in with facebook, though their own PHP SDK is really nice when you get used to it.
Good luck!

Facebook Connect, how to allow users to find and invite friends to your site?

I've read quite a bit of documentation, and it's all based around on setting up full blown Facebook integration on your site to the point where you're completely relying on Facebook.
All I want to know is 2 things:
1) How do I allow my users to find out which of their Facebook friends have already joined my site
2) And what's the easiest way to let them invite Facebook friends to the site?
The site that does it perfectly and exactly how I want to duplicate is Gowalla at http://gowalla.com/friends/find
Note: I've never used Facebook Connect, however I have an API key somewhere.
You need to become best buddies with the Facebook Developer Documentation, especially the web guide.
Where you can start is the Login With Faces plugin, although the Facepile could apply as well. But understand this: If you're not using Facebook to authenticate your users (i.e., using Facebook Connect*), these plugins will be worthless to you.
In terms of inviting people, there's not going to be a great way to do that. You can implement request forms through the XFBML ServerFbml tag, but that's really for inviting people to other Facebook entities, not your own site. There's the share button but that's not really the same thing as an invite.
**Note: It's actually no longer called Facebook Connect - they are slowly moving away from that moniker. They are moving to the terminology "single sign-on". However, the "Facebook Connect" name still pops up in many places.*

When I use facebook connect how much access do I have to the user's friends?

So, if you sign in using facebook on my website, how much access do I have to your friends? I am asking this question because I want for example to know if a user asks me a question about his/her friend, I can go through their Facebook status messages for example and tell them the answer depending on parsing information but do I have access to the user's friends information or no? (And how can I do that if it is possible in another way)
Note that the Facebook API has recently changed (it's now the "Graph API"). As of now, you go to http://graph.facebook.com/username/friends after authenticating with OAuth. As always, there will be copious libraries to help.

Categories