Login   Register  
PHP Classes
elePHPant
Icontem

File: get_statuses.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Manuel Lemos  >  PHP Twitter Feed  >  get_statuses.php  >  Download  
File: get_statuses.php
Role: Example script
Content type: text/plain
Description: Example script to output a RSS feed from statuses of a given user
Class: PHP Twitter Feed
Generate RSS feeds from timelines and searches
Author: By
Last change: Made the type of statuses to retrieve be configurable.
Take parameters from the command line.
Date: 2013-07-03 01:23
Size: 1,480 bytes
 

Contents

Class file image Download
<?php
/*
 * get_statuses.php
 *
 * @(#) $Id: get_statuses.php,v 1.3 2013/06/24 01:25:53 mlemos Exp $
 *
 */

    
require('http.php');
    require(
'oauth_client.php');
    require(
'xml_writer_class.php');
    require(
'rss_writer_class.php');
    require(
'twitter_feed.php');

    
/*
     * Statuses may be mentions_timeline, user_timeline, home_timeline,
     * retweets_of_me
     */
    
$statuses = (IsSet($_GET['statuses']) ? $_GET['statuses'] : 'user_timeline');
    
$parameters = array(
        
'screen_name'=>(IsSet($_GET['screen_name']) ? $_GET['screen_name'] : 'manuellemos')
    );

    
$twitter = new twitter_feed_class;
    
$twitter->debug false;
    
$twitter->debug_http true;

    require(
'configuration.php');

    if(
strlen($twitter->consumer_key) == 0
    
|| strlen($twitter->consumer_secret) == 0)
        die(
'Please access the get_token.php script and set the access_token'.
            
' and access_token_secret in the line '.$token_line.' of the '.
            
$token_file.' configuration script.');

    if((
$success $twitter->Initialize()))
    {
        
$success $twitter->GetStatuses($statuses$parameters);
        
$success $twitter->Finalize($success);
    }
    if(
$twitter->exit)
        exit;
    if(
$success)
    {
        
$twitter->Output();
    }
    else
    {
        
Header('HTTP/1.1 503 Service Temporarily Unavailable');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Twitter Feed error</title>
</head>
<body>
<h1>Twitter feed error</h1>
<pre>Error: <?php echo HtmlSpecialChars($twitter->error); ?></pre>
</body>
</html>
<?php
    
}
?>