title: Twitter API 1.1 get direct messages "Your credentials do not allow access to this resource" error code 220
body: <pre><code>&lt;?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]-&gt;get('account/verify_credentials');
  
          $i++;
      } 
      // -------------------------
  
  
      // Tweetpost döngüsü
      for ($i=0;$i&lt;count($tid);$i++) {
          $screen_name = $bilgi[$i]-&gt;screen_name;
          $profilresmi = $bilgi[$i]-&gt;profile_image_url;
          $kullaniciid = $bilgi[$i]-&gt;id;
          $takipcisayisi = $bilgi[$i]-&gt;followers_count;
  
  
          $tweet = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access, $secret);
  
          $followers = $tweet-&gt;get('direct_messages', array('count' =&gt; '1'));
  
          print_r($followers);
  
      }
      flush();
  ?&gt;
  </code></pre>
  
  <p>When I try to run this codes It says </p>
  
  <pre><code>&gt; stdClass Object ( [errors] =&gt; Array ( [0] =&gt; stdClass Object ( [message] =&gt; Your credentials do not allow access to this resource [code] =&gt; 220 ) ) ) 
  </code></pre>
  
  <p>I want to get direct messages of selected user. But it says like that. Can you help me?</p>