Prompts user to publish feed with PHP SDK
Sorry for my English, I'll try to explain my problem.
With this code I can publish feed on the wall of the users without prompts (I need extended permissions..)
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => 'www.example.com',
'message' => 'Posting with the PHP SDK!'
));
But How can I use PHP SDK to prompts the user to publish as can be done with this code (using Javascript SDK)
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
<p id='msg'></p>
<script>
FB.init({appId: "YOUR_APP_ID", status: true, cookie: t开发者_开发百科rue});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
Thanks to all!
Seems you will need to cUrl
the dialog end point to get the effect you desire.
I would suggest using a button or link and opening a new page which will cUrl the endpoint and redirect back to that page with a close tab or page button.
example endpoint link https://www.facebook.com/dialog/feed?app_id=135669679827333&link=https://developers.facebook.com/docs/reference/dialogs/&picture=http://fbrell.com/f8.jpg&name=Facebook%20Dialogs&caption=Reference%20Documentation&description=Using%20Dialogs%20to%20interact%20with%20users.&redirect_uri=http://anotherfeed.com/?pid=facebook
Refer to: https://developers.facebook.com/docs/reference/dialogs/#display
examples: under construction.
<?php
require 'facebook.php';
// Create our application instance
// (replace this with your appId and secret).
$app_id = "APP_ID";
$secret = "APP_SECRET";
$app_url = "APP_URL";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $secret,
'cookie' => true,
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
$access_token = $facebook->getAccessToken();
}
?>
精彩评论