title: Services_Twitter Pear PHP code - OAuth direct messages suddenly stopped working
body: <p>I have the following PHP code, which up to a week or so ago was working to send Twitter direct messages to a particular user. I now get "<strong>HTTP_OAuth_Exception: Unable to connect to tcp://api.twitter.com:80. Error #0: php_network_getaddresses: getaddrinfo failed: Name of service not known in /usr/share/pear/HTTP/OAuth/Consumer.php on line 257</strong>"</p>
  
  <p>I've searched around and can't find that anything has changed with Twitter since it was working and the server configuration also hasn't changed. I tried using SSL in case Twitter suddenly required connection via SSL, but that gave basically the same error (except it said ssl and port 443).</p>
  
  <p>I'm at a loss to see what's wrong and don't believe anything changed on my side.  My code is based on the example in the Services_Twitter documentation (http://pear.php.net/package/Services_Twitter/docs/latest/Services_Twitter/Services_Twitter.html#var$oauth)</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <pre><code>   require_once 'Services/Twitter.php';
     require_once 'HTTP/OAuth/Consumer.php';
  
     $twitterto = 'xxxxxxxxxxxx';
     $message='This is a test message';
  
     $cons_key='xxxxxxxxxxxx';
     $cons_sec='xxxxxxxxxxxx';
     $auth_tok='xxxxxxxxxxxx';
     $tok_sec='xxxxxxxxxxxx';
  
  try {
     $twitter = new Services_Twitter();
     $oauth = new HTTP_OAuth_Consumer($cons_key,
                                      $cons_sec,
                                      $auth_tok,
                                      $tok_sec);
  
     $twitter-&gt;setOAuth($oauth);
  
     // The error is raised on the following line.
     $twitter-&gt;direct_messages-&gt;new($twitterto, $message);
  
     $twitter-&gt;account-&gt;end_session();
  } catch (Services_Twitter_Exception $e) {
  
       echo $e-&gt;getMessage();
  
  }
  </code></pre>