need help below is the code of index.php of my application and i want to Post on user wall after the user authorize my application with OFFLINE_ACCESS AND publish_stram
<?php
$app_id = "XXXXXXXXXX";
$app_secret = "XXXXXXX";
$canvas_page = "http://apps.facebook.com/esccounsel/";
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page) . ("&scope=read_stream publish_stream offline_access");
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if (empty($data["user_id"])) {
echo("<script> top.location.href='" . $auth_url . "'</script>");
} else {
echo ("Welcome User: " . $data["user_id"]);
}
?>
I want to post directly on user wall please answer
offline_access
permission Get familiar with the PHP-SDK and use the code in the example page as your index, something like:
<?php require '../src/facebook.php'; $facebook = new Facebook(array( 'appId' => 'XXXXXXX', 'secret' => 'XXXXXXXX', 'cookie' => true, )); $session = $facebook->getSession(); $loginUrl = $facebook->getLoginUrl(array( "req_perms" => "publish_stream" )); $me = null; if ($session) { try { $uid = $facebook->getUser(); $me = $facebook->api('/me'); echo "Welcome User: " . $me['name'] . "<br />"; $post_id = $facebook->api("/$uid/feed", "post", array("message"=>"Hello World!")); if(isset($post_id)) echo "A new post to your wall has been posted with id: $post_id"; } catch (FacebookApiException $e) { error_log($e); } } else { echo("<script> top.location.href='" . $loginUrl . "'</script>"); } ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.