drygauost253590142 2014-12-08 06:09
浏览 44

如何取消关注注册我的应用推特的朋友

I want to follow/unfollow some friends who authorize my Twitter app.

For example:

User signs in with my twitter application and he wants to follow some people

How does it work? I wrote some code here but not working, The session works fine, The user signs in but create/friendship not working, why?

<?php
session_start();
require_once('TwitterAPIExchange.php');
require_once('tmhOAuth.php');
require_once('tmhUtilities.php');
require_once('twitteroauth.php');
require 'twconfig.php';
echo $_SESSION['oauth_token'];
echo "<br />";
echo $_SESSION['oauth_token_secret'];

$twitteroauth = new TwitterOAuth($consumerKey, $consumerKeySecret, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret'] );
$twitteroauth->post('friendships/create', array('screen_name' => 'savanpaun'));
?>

Simply put, I want people follow/unfollow friends using signup in my application directly.

  • 写回答

2条回答 默认 最新

  • dpvm7231 2015-01-05 11:51
    关注

    here is a sample code to follow someone.I’ve had used Abraham library you can get it from here https://github.com/abraham/twitteroauth.

    also this is a twitter documentation you can check it out https://dev.twitter.com/rest/reference/post/friendships/create. and to unfollow someone just use 'friendships/destroy'

    <?php
    echo "<pre>";
    $consumerKey = 'your consumer key';
    $consumerSecret = 'your consumer secret key';
    $oAuthToken = 'your oauth token';
    $oAuthSecret = 'your oauth secret';
    
    require_once('twitteroauth.php');
    
    $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
    
    //get friend list
    $list= $tweet->post('friendships/create', array('screen_name' => 'archish9'));
    
    var_dump(json_decode($list));
    print_r($list);
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况