简体   繁体   English

在已登录用户的facebook墙上张贴

[英]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. 嘿,我已经创建了一个小部件,该小部件实际上将解锁音乐曲目,为您提供发布到Twitter帐户或Facebook墙的信息。

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. 我已经通过facebook connect进行了注册,并且能够成功张贴到自己的墙上...但是我要寻找的功能是能够使用一个用户名和密码并自动登录到facebook,然后发送我的所需的消息。 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. 就像我说的,它成功地张贴在我的墙上,只是没有使用字段中的用户名和密码登录到他们各自的facebook并发布。

    <?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) Facebook的API并非旨在像Twitter的API那样(或过去)那样发布。

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. 另请注意,Twitter的API正在删除基本HTTP身份验证。 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. 这意味着您要么必须将用户发送到带有URL编码status参数的Twitter主页上,以设置将被预先填充的消息,否则用户将不得不使用OAuth来授权您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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