Login   Register  
PHP Classes
elePHPant
Icontem

File: get_token.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_token.php  >  Download  
File: get_token.php
Role: Example script
Content type: text/plain
Description: Example script to obtain access tokens for a user to access Twitter statuses
Class: PHP Twitter Feed
Generate RSS feeds from timelines and searches
Author: By
Last change:
Date: 2013-06-21 05:13
Size: 1,183 bytes
 

Contents

Class file image Download
<?php
/*
 * get_token.php
 *
 * @(#) $Id: get_token.php,v 1.1 2013/06/21 12:02:30 mlemos Exp $
 *
 */

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

    
$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 go to Twitter Apps page https://dev.twitter.com/apps/new , '.
            
'create an application, and in the line '.$configuration_line.' of the file '.
            
$configuration_file.' set the consumer_key to Consumer key and '.
            
'consumer_secret with Consumer secret. ');

    if((
$success $twitter->Initialize()))
    {
        
$success $twitter->GetToken();
        
$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
    
}
?>