Reputation: 100
I'm reading the official documentation on facebook to create the application. I found no problems, until I got to the section that explains how to publish your shouts.
How do I use this code? I do not know where to start
curl-F 'access_token =...' \
-F 'message = Hello, Arjun. I like this new API. '\
https: / / graph.facebook.com / Arjun / feed
Upvotes: 1
Views: 936
Reputation: 100
I found the solution:
<?php
$ogurl = "INSERT_YOUR_OG_URL_HERE";
define(FACEBOOK_APP_ID, "YOUR_APP_ID_HERE");
define(FACEBOOK_SECRET, "YOUR_SECRET_KEY_HERE");
$mymessage = "Hello World!";
$access_token_url = "https://graph.facebook.com/oauth/access_token";
$parameters = "type=client_cred&client_id=" . FACEBOOK_APP_ID .
"&client_secret=" . FACEBOOK_SECRET;
$access_token = file_get_contents($access_token_url . "?" . $parameters);
$apprequest_url = "https://graph.facebook.com/feed";
$parameters = "?" . $access_token . "&message=" .
urlencode($mymessage) . "&id=" . $ogurl . "&method=post";
$myurl = $apprequest_url . $parameters;
$result = file_get_contents($myurl);
// output the post id
echo "post_id" . $result;
}
?>
Upvotes: 1
Reputation: 6920
I posted an answer to someone else asking a very similar question, here: facebook extended permissions
If you use the FB PHP SDK you don't need to worry about how to use cURL (though, it's pretty easy, and you can probably find some good information on the curl man page or in the php documentation)
Upvotes: 0
Reputation: 21449
Here you can use facebook sdk. It's a readme file of it explaining how to connect to facebook:
https://github.com/facebook/php-sdk/blob/master/readme.md
And here is a more detailed tutorial
http://thinkdiff.net/facebook/php-sdk-graph-api-base-facebook-connect-tutorial/
Upvotes: 1