How to Process Twitter's API

The Twitter API lets you connect to the Twitter server from a PHP page, search for "tweets" and display these tweets in your blog or website. You process the API return results by writing the results to the page using the PHP "echo" statement. The echo statement is used to display content and dynamically create HTML tags.

Instructions

    • 1

      Right-click the PHP page you want to edit and select "Open With." Click your preferred PHP editor to open the page in your editor.

    • 2

      Get the tweet information you want to process. In this example, the latest tweets for the username "user" are returned:

      $results = "http://search.twitter.com/search.atom?q=from:user&rpp=1";

      Replace "user" with your own Twitter account name.

    • 3

      Process the data returned in the "results" variable and display the content on your webpage. The following code displays the first tweet to the reader's browser:

      $html = explode("<content type=\"html\">", $results);
      $content = explode("</content>", $html[1]);
      echo $content;

    • 4

      Save the changes and open the page in your browser to test the PHP results.

Related Searches:

References

Comments

Related Ads

Featured