简体   繁体   English

Twitter API 1.1获得直接消息“您的凭据不允许访问此资源”错误代码220

[英]Twitter API 1.1 get direct messages “Your credentials do not allow access to this resource” error code 220

<?php  
    require_once('twitteroauth/twitteroauth.php');
    require_once('config.php');
    require_once('function.php');
    header("Content-Type: text/html; charset=utf-8"); 



    // Datadan kullanıcı çekiliyor
    $a = mysql_query("select * from users WHERE twid = 326960131");
    $i=0;
    while ($b = mysql_fetch_array($a)) { 
        $oauth_token[$i] = $b["oauth_token"]; 
        $oauth_secret[$i] = $b["oauth_secret"];
        $tid[$i]=$b["twid"];
        $connection[$i] = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token[$i], $oauth_secret[$i]);
        //Tüm bilgilerin kaynağı alınıyor
        $bilgi[$i] = $connection[$i]->get('account/verify_credentials');

        $i++;
    } 
    // -------------------------


    // Tweetpost döngüsü
    for ($i=0;$i<count($tid);$i++) {
        $screen_name = $bilgi[$i]->screen_name;
        $profilresmi = $bilgi[$i]->profile_image_url;
        $kullaniciid = $bilgi[$i]->id;
        $takipcisayisi = $bilgi[$i]->followers_count;


        $tweet = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access, $secret);

        $followers = $tweet->get('direct_messages', array('count' => '1'));

        print_r($followers);

    }
    flush();
?>

When I try to run this codes It says 当我尝试运行此代码时,它说

> stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Your credentials do not allow access to this resource [code] => 220 ) ) ) 

I want to get direct messages of selected user. 我想获得所选用户的直接消息。 But it says like that. 但是它是那样说的。 Can you help me? 你能帮助我吗?

There are two possible problems. 有两个可能的问题。

  1. Are you the authenticating user? 您是认证用户吗? Using the API you can only get your own messages. 使用API​​,您只能获得自己的消息。
  2. Check the permissions of your app on https://apps.twitter.com/ - did you request DM access, or read-only access? https://apps.twitter.com/上检查应用程序的权限-您是否请求DM访问或只读访问?

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

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