Created
August 19, 2012 04:33
-
-
Save rukshn/3392066 to your computer and use it in GitHub Desktop.
A simple Facebook social reader app. This can be improved a lot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app_id = "xxxxxxx"; //facebook app id | |
$redirect_url = "xxxxxx"; //url to redirct after getting the token, should be in the same domain of the canvas url | |
$app_secret = "xxxxxxx"; //facebook app secret | |
session_start(); | |
$code = $_REQUEST['code']; | |
if(empty($code)) | |
{ | |
$outh_url = "https://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode($redirect_url) . "&scope=publish_actions"; | |
header('Location:' . $outh_url); | |
} | |
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $app_id . "&redirect_uri=" . urlencode($redirect_url) . "&client_secret=" . $app_secret . "&code=" . $code; | |
$response = file_get_contents($token_url); | |
parse_str($response, $params); | |
$acctoken = $params['access_token']; | |
//echo $acctoken; | |
//echo "/n" . $toktok; | |
$data = array('access_token' => $acctoken , 'article' => URL); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL,"https://graph.facebook.com/me/NAMESPACE_OF_APP:publish"); | |
curl_setopt($curl, CURLOPT_POST, 1); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); | |
curl_exec ($curl); | |
curl_close ($curl); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment