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);
I’m trying to create a $twitteroauth object in order to use the next code:
$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'));
}
What I’m trying to do is to follow users who log in to my site using twitter, any idea what’s wrong? I’m kind of new with the twitter API.
please go to twitter dev – > My app – > Your App -> settings -> Application type set to Read, Write and Access direct messages.
First you are checking if you have already followed the person. to do this 2 parameters are required ,.
Now the 2nd call will be to follow method so you could follow, for this 1 param is req.
For above mentioned please make sure you are calling methods with appropriate param.
e.g.) in the first you need to pass 4 param, client_id, client_secret , outhid, outhsecret
initially before this user needs to authenticate the app.
everything else lloks fine hope you passing proper param thats just one concern.