Twitter feed authentication (API 1.1) for search

27 April, 2013 by Tom Elliott

This is comment page 2 for Twitter feed authentication (API 1.1) for search »


Creating a Twitter Search & Analytics tool »


101 Comments

  • kruben says:

    Hey,

    Your tutorial is very good. Had no trouble to follow. But is it possible to display a 1 user and only his tweets with a certain Hashtag? I want to filter some non-relevant tweets so that you can see only tweets with a certain topic.
    If there isnt already a solution it would be like a mix from your two tutorials (show user tweets and show a search).
    would not be cool if I have to check every tweet with a custom php script. Maybe you have a solution for it 😀

  • kruben says:

    Edit: I solved my Problem. i added an if under the “isdirect message if” on line ~50:
    if (feeds[i].text.indexOf(“#fifa”)>=0) {
    hashtagfilter = true;
    }
    Then I added the variable in the if where everthing will get checked with: (&& hashtagfilter == true)

    sorry for my bad english.

  • Justin says:

    thx for your tutorial..

    using https://github.com/abraham/twitteroauth with LAMP stack. I am getting the following issue that I can’t seem to resolve…

    XMLHttpRequest cannot load https://api.twitter.com/oauth/authenticate?oauth_token=w7UW73yGTw4RzHqyb6OfqPUenMLU78GeqiNPN0E8No8. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://bmkaradia.in’ is therefore not allowed access.

    • Tom Elliott says:

      Hi Justin, looks like a cross-domain issue – I would guess your tweets PHP file is being loaded from the ‘www’ whereas your trying to access the feed from the non-www.

  • Mike says:

    Hi Tim,

    Thanks for your tutorial. Do you have an example where you use the carousel and autorefresh at the same time? I got it working for myself, but when the autorefresh fires off, it resets the entire list and doesn’t look as fluid as I’d like it to be.

  • Bryce says:

    In theory, would a search for a specific username be exactly the same as the other method (using $twitteruser in the get tweets file)?

    For some reason, the $twitteruser method works, but searching for the same user returns no tweets.

    Do you know why this is?

    Thanks!

  • ionica says:

    Hello,

    I use this code for showing the last twitter post on my timeline. I need your help to get those t.co link expanded, I’ve searched everywhere but no success. Thanks in advance, ionica.

    $connection = new TwitterOAuth($twitter_customer_key, $twitter_customer_secret, $twitter_access_token, $twitter_access_token_secret);

    $my_tweets = $connection->get(‘statuses/user_timeline’, array(‘screen_name’ => ‘i0n1ca’, ‘count’ => 1));

    echo ”;
    if(isset($my_tweets->errors))
    {
    echo ‘Error :’. $my_tweets->errors[0]->code. ‘ – ‘. $my_tweets->errors[0]->message;
    }else{
    echo makeClickableLinks($my_tweets[0]->text);
    }
    echo ”;

    //function to convert text url into links.
    function makeClickableLinks($s) {
    $s = preg_replace(‘@(https?://([-w.]+[-w])+(:d+)?(/([w/_.#-]*(?S+)?[^.s])?)?)@’, ‘$1‘, $s);
    $s = preg_replace(‘/(^|s)#(w*[a-zA-Z_]+w*)/’, ‘1#2‘, $s);
    $s = preg_replace(‘/[@]+([A-Za-z0-9-_]+)/’, ‘@$1‘, $s );
    echo $s;

    }

    • Tom Elliott says:

      Hi Ionica, although not covered in this post, you’ll have to drill down to the statuses->entities->urls array which contains the ‘expanded_url’ field for any tweets with links. print_r($my_tweets) should help locate this.

  • Rahul says:

    Hi Tom,

    I followed your steps in the above tutorial.After running the php file i am getting the error
    {“errors”:[{“message”:”Sorry, that page does not exist”,”code”:34}]}.

    Please help me to figure out this issue.

  • amee says:

    thank you so much 🙂

  • Kim says:

    hello Tom. i have a one question…
    your PHP cord change to jquery possible:
    (your php cord—> jquery) i need jquery cord

    Plz posting to jquery…..

    So i want your jquery combine your javascript ..Help Me

  • Nicole says:

    Hello,

    I am trying to update our WordPress template by adding a hash tag twitter feed and I am trying to use your solutions. But WordPress seems to have an issue with the -> operator and interprets it as a closed HTML bracket… Do you know how I could fix this?