Post on Facebook without Share Prompt in PHP -
is there possibility can make button on when click, contents directly shared on facebook without showing our user share prompt dialog box?
i referred online , found possible through mobile devices: http://www.mindfiresolutions.com/how-to-post-message-on-your-facebook-wall-without-using-facebook-dialog-box-1419.php
the question can make sort of ajax call , done on web apps.
we used following code
<?php require_once('php-sdk/facebook.php'); $config = array( 'appid' => 'my app id', /*your app id*/ 'secret' => 'my secret id', /*your app secret key*/ 'allowsignedrequest' => false ); $facebook = new facebook($config); $user_id = $facebook->getuser(); if($user_id) { try { $user_profile = $facebook->api('/me','get'); } catch(facebookapiexception $e) { $login_url = $facebook->getloginurl(); echo 'please <a href="' . $login_url . '">login.</a>'; error_log($e->gettype()); error_log($e->getmessage()); } } else { // no user, print link user login $login_url = $facebook->getloginurl(); echo 'please <a href="' . $login_url . '">login.</a>'; } $response = $facebook->api( "/me/feed", "post", array ( 'message' => 'this test message', 'link' => 'www.google.com' /* 'picture' => '{picture}', 'caption' => '{caption}', 'description' => '{description}'*/ ) ); ?>
but returns : " fatal error: uncaught oauthexception: (#200) user hasn't authorized application perform action throw in file" highly appreciated.
thanks in advance.
of course can using graph api. on button click have make \post
call /me/feed
.
learn more publishing feed via graph api , parameters available here.
permission required: publish_stream
using php sdk:
$response = $facebook->api( "/me/feed", "post", array ( 'message' => 'this test message', 'link' => '{link}', 'picture' => '{picture}', 'caption' => '{caption}', 'description' => '{description}' ) );
direct http request-
post /me/feed host: graph.facebook.com message=this+is+a+test+message ...
you can check calls in graph api explorer
edit:
to ask required permissions:
$params = array( 'scope' => 'publish_stream' ); $login_url = $facebook->getloginurl($params);
you can read more permissions here.
Comments
Post a Comment