如何关注在我的网站上使用 Twitter 登录的用户


How to follow users who sign in with twitter on my website?

require("twitteroauth/twitteroauth.php");  
session_start();
//Site Account
$siteauth = new TwitterOAuth('{Consumer key}', '{Consumer secret}', '{Access token}', '{Access token secret}');
$access_token = $siteauth->getAccessToken($_GET['oauth_verifier']);
$_SESSION['access_token'] = $access_token;
$site_info = $siteauth->get('account/verify_credentials');
var_dump($site_info);

我正在尝试创建一个$twitteroauth对象以使用下一个代码:

$follows_faelazo = $siteauth->get('friendships/exists', 'MY-VISTOTR-ACCOUNT', 'user_b' => 'MY-SITE_ACCOUNT'));
if(!$follows_faelazo){
    echo 'You are NOT following @faelazo!';
    $siteauth->post('friendships/create', array('screen_name' => 'MY-VISTOR'));
}

我想做的是关注使用Twitter登录我的网站的用户,知道出了什么问题吗?我对推特API有点陌生。

请转到 Twitter dev ->我的应用 ->你的应用 ->设置 -> 应用程序类型设置为读取、写入和访问直接消息。

首先,您要检查您是否已经关注了此人。 为此,需要 2 个参数。

 // uname
 1.) USER_FOLLOWING
 2.) USER_FOLLOWED

现在第二个调用将是遵循方法,以便您可以遵循,因为这 1 个参数是 req。

//this can be uid/uname
1.) USER_T0_BE_FOLLOWED

对于上述内容,请确保使用适当的参数调用方法。

例如(在第一个你需要传递4个参数,client_id,client_secret,隐藏,外秘密

最初在此用户需要对应用进行身份验证之前。

其他一切都很好,希望您传递适当的参数,这只是一个问题。