<?php
$app_id = "12DCND106CND4377308";
$app_secret = "0e34cb1ccf7DCNJSDC5b535JDCBDJ3a514SDCXNDSJCa74";
//Take NOTE: this must include http://
//ex. http://sharefavoritebibleverses.com/fb_connect.php
$post_login_url = "http://www.japiface.com/ahoraunpoema/admin/admin.php";
$code = $_REQUEST["code"];
//Obtain the access_token with publish_stream permission
if(empty($code))
{
$dialog_url= "http://www.facebook.com/dialog/oauth?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&scope=publish_stream,manage_pages";
echo("<script>top.location.href='" . $dialog_url
. "'</script>");
}
else
{
$token_url="https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&client_secret=" . $app_secret
. "&code=" . $code;
$response = file_get_contents($token_url);
$page_info = null;
parse_str($response, $page_info);
$access_token = $page_info['access_token'];
// Show photo upload form to user and post to the Graph URL
$graph_url = "https://graph.facebook.com/434015300027264/photos?"
. "access_token=" .$access_token;
echo '<html><body>';
echo '<form enctype="multipart/form-data" action="'
.$graph_url .' "method="POST">';
echo 'Please choose a photo: ';
echo '<input name="source" type="file" ><br/><br/>';
echo 'Say something about this photo: ';
echo '<input name="message"
type="text" value=""><br/><br/>';
echo '<input type="submit" value="Upload"/><br/>';
echo '</form>';
echo '</body></html>';
}
?>