Php Guru That Is Familiar With Twitter Wanted

4 replies
Looking to solve this. This is the error I get

http://img841.imageshack.us/img841/9560/errorreport.png

I'm on a namecheap shared hosting account which should have curl so I do not know why this error comes up.

email: money.marketing85@gmail.com
skype: phill.george

This is the php code


<?php
function twitterCapture() {
// Set your username and password here
$user = 'ENTER USERNAME HERE'; // Twitter Username
$password = 'ENTER PASSWORD HEREc'; // Twitter Password

$tw = curl_init("http://twitter.com"); //grabs the JSON format of your timelines
curl_setopt($tw,CURLOPT_TIMEOUT, 30); // Timeout (for when Twitter is down)
curl_setopt($tw,CURLOPT_USERPWD,$user . ":" . $password); // Uses your username and password
curl_setopt($tw,CURLOPT_RETURNTRANSFER,1); // returns
$json = curl_exec ($tw); // Executes the cURL and puts it into the varible
return $json; // returns what was grabbed
}
$cachefile = 'cache/twitterCache.json'; // the location to your cache file
$cachetime = 10 * 60; // set the cach time 10 * 60 (1 hour)
// if the file exists // if and the time it was created is less then cache time
if ( (file_exists($cachefile)) && ( time() - $cachetime < filemtime($cachefile) ) ) {
// script will not use the cached version
}else{ // the file didn't exist or is old
ob_start(); // turn on the output buffering
fwrite($fp, twitterCapture()); // writes to the file what was grabbed from the previouse function
fclose($fp); // closes
ob_end_flush(); // finishes and flushes the output buffer
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Little Twitter Widget</title>

<!-- Start of CSS -->
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<!-- Start of JS -->
<script type="text/javascript" src="js/jquery-1.4.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<div id="twitter_widget_top" class="center" ></div><!-- The top of the widget -->
<div id="twitter_widget_body" class="center"> <!-- The body wrap -->

<div id="twitter_widget_tweet"> <!-- The tweet area -->
<div id="twitter_movement"> <!-- To position the icon reletive to -->
<a id="twitter_icon" href="http://twitter.com/"></a> <!-- Twitter icon -->
<div id="twitterWrap"> <!-- The blue area -->
<div id="twitter"> <!-- The main twitter data -->
<noscript>JavaScript must be on to view tweets</noscript> <!-- Incase no js -->
<p class="tweet">Loading...</p> <!-- The Tweet -->
<p class="created_at"></p> <!-- Date created -->
</div>
</div>
<p class="clear"></p> <!-- Clear the floats -->
</div>
<a href="" class="previous tweetNav"></a><!-- Next button -->
<p class="follow_me">Follow me - <a href="http://twitter.com/alexanderbor" class="screen_name"></a></p> <!-- Follow me link -->
<a href="" class="next tweetNav"></a> <!-- Pre button -->
<p class="clear"></p>
</div>
</div>
<div id="twitter_widget_bottom" class="center"></div><!-- Bottom of widet -->
<p class="info">Join my <span class="followedNumber"></span> followers - <span class="user_name"></span></p>
</body>
</html>
#familiar #guru #php #twitter #wanted
  • Profile picture of the author SteveJohnson
    Two things - the first is that the address you're trying to retrieve the data from isn't a valid address.
    Code:
    http://twitter.com
    is just twitter's home address.

    Second and most importantly, the code you're working with won't work. Twitter has transitioned to a different authentication scheme called OAuth. Their implementation is complicated and a PITA. Simple username/password authentication won't work any more.

    Visit the developer section of Twitter for more information and client libraries.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[2675343].message }}
  • Profile picture of the author SmartWeb
    Originally Posted by George Phillip View Post

    Looking to solve this. This is the error I get

    http://img841.imageshack.us/img841/9560/errorreport.png

    I'm on a namecheap shared hosting account which should have curl so I do not know why this error comes up.

    email: money.marketing85@gmail.com
    skype: phill.george

    This is the php code


    <?php
    function twitterCapture() {
    // Set your username and password here
    = 'ENTER USERNAME HERE'; // Twitter Username
    = 'ENTER PASSWORD HEREc'; // Twitter Password

    = curl_init("http://twitter.com"); //grabs the JSON format of your timelines
    curl_setopt(,CURLOPT_TIMEOUT, 30); // Timeout (for when Twitter is down)
    curl_setopt(,CURLOPT_USERPWD, . ":" . ); // Uses your username and password
    curl_setopt(,CURLOPT_RETURNTRANSFER,1); // returns
    = curl_exec (); // Executes the cURL and puts it into the varible
    return ; // returns what was grabbed
    }
    = 'cache/twitterCache.json'; // the location to your cache file
    = 10 * 60; // set the cach time 10 * 60 (1 hour)
    // if the file exists // if and the time it was created is less then cache time
    if ( (file_exists()) && ( time() - < filemtime() ) ) {
    // script will not use the cached version
    }else{ // the file didn't exist or is old
    ob_start(); // turn on the output buffering
    fwrite(, twitterCapture()); // writes to the file what was grabbed from the previouse function
    fclose(); // closes
    ob_end_flush(); // finishes and flushes the output buffer
    }
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Little Twitter Widget</title>

    <!-- Start of CSS -->
    <link rel="stylesheet" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <!-- Start of JS -->
    <script type="text/javascript" src="js/jquery-1.4.js"></script>
    <script type="text/javascript" src="js/main.js"></script>
    </head>
    <body>
    <div id="twitter_widget_top" class="center" ></div><!-- The top of the widget -->
    <div id="twitter_widget_body" class="center"> <!-- The body wrap -->

    <div id="twitter_widget_tweet"> <!-- The tweet area -->
    <div id="twitter_movement"> <!-- To position the icon reletive to -->
    <a id="twitter_icon" href="http://twitter.com/"></a> <!-- Twitter icon -->
    <div id="twitterWrap"> <!-- The blue area -->
    <div id="twitter"> <!-- The main twitter data -->
    <noscript>JavaScript must be on to view tweets</noscript> <!-- Incase no js -->
    <p class="tweet">Loading...</p> <!-- The Tweet -->
    <p class="created_at"></p> <!-- Date created -->
    </div>
    </div>
    <p class="clear"></p> <!-- Clear the floats -->
    </div>
    <a href="" class="previous tweetNav"></a><!-- Next button -->
    <p class="follow_me">Follow me - <a href="http://twitter.com/alexanderbor" class="screen_name"></a></p> <!-- Follow me link -->
    <a href="" class="next tweetNav"></a> <!-- Pre button -->
    <p class="clear"></p>
    </div>
    </div>
    <div id="twitter_widget_bottom" class="center"></div><!-- Bottom of widet -->
    <p class="info">Join my <span class="followedNumber"></span> followers - <span class="user_name"></span></p>
    </body>
    </html>
    I feel you are trying to connect twitter using old way of user-id and password, from last month they have stopped any connection via this way, now all conections shall be via oauth.

    Twitter Blog: Twitter Applications and OAuth
    {{ DiscussionBoard.errors[2675358].message }}
  • Profile picture of the author George Phillip
    Thank you, the person this was outsourced to took it in the wrong direction and I needed some clarification before I pass the job to another worker.
    Signature
    {{ DiscussionBoard.errors[2679011].message }}
  • Profile picture of the author SpydrZero
    twitter oauth is good however they have changed the amount of API requests
    {{ DiscussionBoard.errors[6348596].message }}

Trending Topics