Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6701871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:59:09+00:00 2026-05-26T06:59:09+00:00

I am working on a PHP twitter feed for my web-site . So far

  • 0

I am working on a PHP twitter feed for my web-site. So far I have figured out how to output date, but what I’m looking to do is pick out the urls and hyperlink them. I also would like to pick out the #hashtags, hyperlink them to search twitter. I’m just starting to learn PHP, so any help would be appreciated.

<?php
    $count = 5;
    $tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/atrueresistance.json?count=".$count."" ));
    for ($i=1; $i <= $count; $i++){   
        echo "<div class='tweet'>".$tweet[($i-1)]->text."                
            <div class='tweet_date'>". date("M \- j",strtotime($tweet[($i-1)]->created_at))."
            </div>
        </div>";   
     }    
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:59:10+00:00Added an answer on May 26, 2026 at 6:59 am

    Since no one is responding to this, I figured it is about time I put what code I came up with.

    Enjoy!

    <?php
    
    $count = 5;
    $tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/atrueresistance.json?count=".$count."" ));
    for ($i=1; $i <= $count; $i++){
        //Assign feed to $feed
        $feed = $tweet[($i-1)]->text;
        //Find location of @ in feed
        $feed = str_pad($feed, 3, ' ', STR_PAD_LEFT);   //pad feed     
        $startat = stripos($feed, '@'); 
        $numat = substr_count($feed, '@');
        $numhash = substr_count($feed, '#'); 
        $numhttp = substr_count($feed, 'http'); 
        $feed = preg_replace("/(http:\/\/)(.*?)\/([\w\.\/\&\=\?\-\,\:\;\#\_\~\%\+]*)/", "<a href=\"\\0\">\\0</a>", $feed);
        $feed = preg_replace("(@([a-zA-Z0-9\_]+))", "<a href=\"http://www.twitter.com/\\1\">\\0</a>", $feed);
        $feed = preg_replace('/(^|\s)#(\w+)/', '\1<a href="http://search.twitter.com/search?q=%23\2">#\2</a>', $feed);
        echo "<div class='tweet'>".$feed.  "<div class='tweet_date'>". date("M \- j",strtotime($tweet[($i-1)]->created_at))."
                </div></div>";      
        }?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a web-developer working in PHP. I have some limited experience with using
I'm working on a site with a simple php-generated twitter box with user timeline
I'm trying to parse a Twitter atom feed in PHP but am running into
Twitter lists the PHP Libraries below on their developer site. I'm working my way
I'm in PHP working on an Euler problem. I have this function so far:
I am working with php and want to have a page that has a
at my working place (php only) we have a base class for database abstraction.
I'm used to working with PHP but lately I've been working with Java and
Recently, I was working with PHP. In PHP we have a powerful template engine
I have developed a simple site that fetches tweets from the Twitter public timeline,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.