Twitter读错误

this is the error I'm getting:

Warning: simplexml_load_file(http://api.twitter.com/1/statuses/user_timeline/razefm.xml?count=4): failed to open stream: HTTP request failed! HTTP/1.0 410 Gone in /home/tweets.php on line 44

Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://api.twitter.com/1/statuses/user_timeline/razefm.xml?count=4" in /home/tweets.php on line 44

What I have on line 44 is:

$url = "http://api.twitter.com/1/statuses/user_timeline/{$username}.xml?count=4";
$feed   = simplexml_load_file($url); <--- Line 44

I know twitter made some recent changes to it's API, but for some reason, I don't know what it is that I'm doing wrong. Any suggestions?

This is what I have on my index:

<?php
          $username = "razefm";//your twitter username
          $number = 4;//number of tweets
          include ("{$dir}/php/tweets.php");
          ?>

If you point your browser to the URL in your first error message, you'll see this message: "The Twitter REST API v1 is no longer active. Please migrate to API v1.1."

In brief: You'll need a Twitter developer account, an "App" in Twitter, and your PHP must be changed to read a response coming in JSON, not in XML.

For more details, have a look at this question: Simplest PHP example for retrieving user_timeline with Twitter API version 1.1.

But maybe what you want is just an Embedded Timeline that directly puts your tweets (with the possibility to reply and all) on a web page? In your Twitter account settings, you can create a Widget for this. Set the options and copy & paste the HTML code on your page.

Twitter API v1 is no longer active. you will need to move on to new API (v 1.1).

If you are looking for really simple Twitter library I recommend mine https://github.com/vojant/Twitter-php

Ofcourse you have to create Twitter application to interact with Twitter api, you can do it here: https://dev.twitter.com/apps

If you want to read user's timeline here's example:

$consumerKey = YOUR TWITTER CONSUMER KEY
$consumerSecret = YOUR TWITTER CONSUMER SECRET
$accessToken = YOUR TWITTER ACCESS TOKEN
$accessTokenSecret = YOUR TWITTER ACCESS TOKE SECRET

//Name of Twitter user
$userName = '';

$twitter = new \TwitterPhp\RestApi($consumerKey,$consumerSecret,$accessToken,$accessTokenSecret);
$connectionUser = $twitter->connectAsUser();
$connectionUser->get('statuses/user_timeline',array('screen_name' => $userName));