Login   Register  
PHP Classes
elePHPant
Icontem

File: get_search.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_search.php  >  Download  
File: get_search.php
Role: Example script
Content type: text/plain
Description: Example script to output a RSS feed from results of searching tweets
Class: PHP Twitter Feed
Generate RSS feeds from timelines and searches
Author: By
Last change: Take parameters from the command line.
Date: 2013-07-03 01:23
Size: 1,287 bytes
 

Contents

Class file image Download
<?php
/*
 * get_search.php
 *
 * @(#) $Id: get_search.php,v 1.2 2013/06/21 12:46:36 mlemos Exp $
 *
 */

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

    
$parameters = array(
        
'q'=>(IsSet($_GET['q']) ? $_GET['q'] : '"PHP Classes" OR phpclasses')
    );

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

    require(
'configuration.php');

    if(
strlen($twitter->access_token) == 0
    
|| strlen($twitter->access_token_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->GetSearch('tweets'$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
    
}
?>