簡體   English   中英

如何關注在我的網站上使用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登錄到我的網站的用戶,有什么想法嗎? 我對twitter API很陌生。

請轉到twitter dev- >我的應用程序->您的應用程序->設置->應用程序類型設置為讀取,寫入和訪問直接消息。

首先,您要檢查您是否已經關注此人。 為此,需要2個參數。

 // uname
 1.) USER_FOLLOWING
 2.) USER_FOLLOWED

現在第二個調用將是follow方法,因此您可以遵循,因為這1個參數是req。

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

對於上述內容,請確保您正在調用具有適當參數的方法。

例如)首先,您需要傳遞4個參數,client_id,client_secret,outhid,outhsecret

最初在此用戶需要驗證應用程序之前。

一切都會好起來,希望您傳遞適當的參數,這只是一個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM