views:

375

answers:

2

Hi guys, I am creating a little flash game for the facebook platform, but I am finding it very difficult to get any decent documentation on the graph api and the PHP SDK, so if anyone has a decent resource for a beginner to go and learn the basics, I would appreciate it very much, as I am struggling to grasp the concept.

Thanx!

+1  A: 

I agree that the docs can be pretty hard work for facebook. If you are looking to use the Graph API tho, bear in mind that it is just a REST API that uses oAuth for authentication, much the same as Twitter, SoundCloud etc.

The most awkward bit I found was authenticating properly so I would suggest checking out the oAuth website

http://oauth.net/

They also have some PHP samples which were what I used as a starting point. I'd definitely recommend starting from these rather than trying to build your own setup from scratch.

http://oauth.googlecode.com/svn/code/php/

I also found it handy to refer to the docs on some of the other sites that use oAuth, such as Twitter and SoundCloud as it helped build my overall understanding of what is going on, even if there were a few small differences from one site to another

http://apiwiki.twitter.com/Authentication

http://wiki.github.com/soundcloud/api/02-authentication

Personally I would suggest just trying to do a basic oAuth-authenticated request to begin with. Facebook Graph has a few extra options such as using scope for extended permissions. Whilst you will probably need to use these in the end, once you get your head round the signing mechanism its easy enough to add in these extra details.

Once you have got the hang of signing requests, it is just a case of requesting the appropriate endpoint for what you want using either curl or any other method that takes your fancy.

Hope this is of some use

Addsy
Thank you for the explanation! It will help a lot!
Wouldn't it be far far simpler to just use the Facebook PHP SDK? It takes care of a lot of the manual work for you.
Evans
Not sure if there is a new PHP SDK for the Graph API. If not, using this method is the best way to avoid rewrites in the future - Facebook are making a pretty strong move away from the old API. They say themselves to use the new API where possible. Even if there is a new SDK for this API, it's worth learning these techniques properly because OAuth and REST are fast becoming the standard way of interacting with these type of sites. Learn this and the same principles then apply for Twitter, SoundCloud, MySpace, Google and a whole bunch more.
Addsy
OK, just did some checking and there is a new PHP SDK available for the Graph API and it looks pretty good (was never a big fan of the old one). So I guess whether to use that or to set up your own way of doing it depends on your other plans - if you only need to work with Facebook, use the SDK. If you want to connect to other sites as well, you may as well try and use oAuth directly cos then you can reuse exactly the same code for the rest of your integrations. Personally I have an OAuthProvider class I built that I can then subclass, change a few small details (urls etc) and that's job done
Addsy
A: 

I'm having exactly the same problem, a beginner muddling through and none of it seems to make any sense.

Lauren
I have gotten past a lil bit of the basics, I am by NO means a expert, but I would be happy to help where I can, just drop me a message! This helped me to get the basics down, http://www.phpfour.com/blog/2010/05/quick-start-on-new-facebook-php-sdk-iframe-based/ hope it helps!