duanfu5239 2010-05-06 22:53
浏览 36
已采纳

在登录用户Facebook墙上发布

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

  • 写回答

1条回答 默认 最新

  • duanqiaoren9975 2010-05-06 23:48
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)