简体   繁体   中英

Post on a logged in users facebook wall

Hey all, I've created a widget that will essentially unlock a music track, providing you post to either your twitter account, or facebook wall.

I've signed up through facebook connect and I am able to successfully post onto my own wall... but the functionality I'm looking for is to be able to take ones username and password and automatically log in to facebook, and send my desired message. Like I said, it posts on my wall successfully, it's just not using the username and password from the field to log in to their respective facebooks and post.

    <?php

$facename = $_POST['facename'];
$facepass = $_POST['facepass'];
define('FB_APIKEY', 'my_api_key');

define('FB_SECRET', 'my_secret_phrase_');

define('FB_SESSION', 'my_session_id');

require_once('facebook.php');

echo "post on wall";

try {

$facebook = new Facebook(FB_APIKEY, FB_SECRET);

$facebook->api_client->session_key = FB_SESSION;

$fetch = array('friends' =>

array('pattern' => '.*',

'query' => "select uid2 from friend where uid1={$facename}"));

echo $facebook->api_client->admin_setAppProperties(array('preload_fql' => json_encode($fetch)));

$message = 'I downloaded Automatic Loveletter\'s new single \'To Die For\' here!';

if( $facebook->api_client->stream_publish($message))

echo "Added on FB Wall";

} catch(Exception $e) {

echo $e . "<br />";

}

?>

Any help in the right direction is greatly appreciated! Thanks, Matt

Facebook's API is not really designed to be able to post like Twitter's API is (or used to be)

To post on another user's wall, they have to authorize your application to make posts to their wall. Ideally, they will never give you their username or password. Ever.

Also note that Twitter's API is removing Basic HTTP Authentication. Meaning that you will either have to send the user to the Twitter Home Page with a URL-Encoded status parameter to set the message that will be pre-filled in, or the user will have to use OAuth to authorize your application.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM