Available for hire...
ask for a free quote
I can work from anywhere in the world
Before I start it would be great if people showed their own implementations in PHP or ANY other languages. I will then list it in the post and give you a link back. Please post your solutions.
After reading facebooks one page of documentation on how to gain auth for their API I was left stuck with just the curl command they supply which at the time had know idea at all on how to convert it to php-cURL. I also wanted to run the script on shared/secured servers that didn’t allow me to use the exec() php command. I couldn’t find the PHP solution on Google to get a Facebook token. So I had to figure it out for myself -.-
I have never used cURL extensivly and found it quite tricky converting facebooks original steps(shown below) into PHP steps.
curl -F type=client_cred \ -F client_id=your_app_id \ -F client_secret=your_app_secret \ https://graph.facebook.com/oauth/access_token
After blood,sweat and tears(5mins) I finally got a server response
$url = "https://graph.facebook.com/oauth/access_token"; $client_id = "xxxxxxxxxxxxxxxxx"; $client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $postString = "client_id=$client_id&client_secret=$client_secret&type=client_cred"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FAILONERROR, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $postString); $response = curl_exec($curl);
If anyone knows a better or faster way that works on a standard PHP server, please tell me. Sorry you have to replace & with & in the code above, my code highlighter sucks.
Also I can’t find quick solutions for getting an access token for pretty much any language so please leave behind your quick and dirty solutions. It would be great resource to have.
Also heres another tip, to get some quick and useful information of a url on facebook simply append it to the open graph url. like this
If you found that useful scroll to the top and press my like button!
Again if you have useful or cool tip for Open Graph, comment below and I will list it in the post with full credits!
Popularity: 53% [?]