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 7934797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:44:22+00:00 2026-06-03T21:44:22+00:00

I use SimpleXML to get my tweets via RSS. I want to make links

  • 0

I use SimpleXML to get my tweets via RSS. I want to make links clickable on the tweets.
But i could not figure how. I tried somethings that did not work.
Your helps needed.

Here is my code;

<? 
$twitterRssFeedUrl =  "https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=puzzletravel";
$twitterUsername = "puzzletravel";
$amountToShow = 5;

$twitterPosts = false;
$xml = @simplexml_load_file($twitterRssFeedUrl);
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$text = $xml;
if(is_object($xml)){
    //Rest of our code will be here
}else{
    die('cannot connect to twitter feed');
}

foreach($xml->channel->item as $twit){
    if(is_array($twitterPosts) && count($twitterPosts)==$amountToShow){
        break;
    }
     $d['title'] = stripslashes(htmlentities($twit->title,ENT_QUOTES,'UTF-8'));
    $description = stripslashes(htmlentities($twit->description,ENT_QUOTES,'UTF-8'));
    if(strtolower(substr($description,0,strlen($twitterUsername))) == strtolower($twitterUsername)){
        $description = substr($description,strlen($twitterUsername)+1);
    }
    $d['description'] = $description;
    $d['pubdate'] = strtotime($twit->pubDate);
    $d['guid'] = stripslashes(htmlentities($twit->guid,ENT_QUOTES,'UTF-8'));
    $d['link'] = stripslashes(htmlentities($twit->link,ENT_QUOTES,'UTF-8'));
    $twitterPosts[]=$d;
}

if(is_array($twitterPosts)){
    echo '<ul>';
    foreach($twitterPosts as $post){
        echo '<li><p>'.$post['description'].'</p><p class="date">'.date(' j F',$post['pubdate']).'</p></li>';
    }
    echo '</ul>';
}else{
    echo '<p>No Twitter posts have been made</p>';
}

?>
  • 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-06-03T21:44:23+00:00Added an answer on June 3, 2026 at 9:44 pm

    I found a solution for my problem. Here is the solution for those whom might need.
    This solution converts text which contains http,https to clickable url.

    <? 
    $twitterRssFeedUrl =  "https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=puzzletravel";
    $twitterUsername = "puzzletravel";
    $amountToShow = 7;
    
    $twitterPosts = false;
    $xml = @simplexml_load_file($twitterRssFeedUrl);
    $reg_exUrl = "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
    
    if(is_object($xml)){
        //Rest of our code will be here
    }else{
        die('Tweetler Alinamiyor');
    }
    
    foreach($xml->channel->item as $twit){
        if(is_array($twitterPosts) && count($twitterPosts)==$amountToShow){
            break;
        }
         $d['title'] = stripslashes(htmlentities($twit->title,ENT_QUOTES,'UTF-8'));
        $description = stripslashes(htmlentities($twit->description,ENT_QUOTES,'UTF-8'));
        if(strtolower(substr($description,0,strlen($twitterUsername))) == strtolower($twitterUsername)){
            $description = substr($description,strlen($twitterUsername)+1);
        }
        $d['description'] = $description;
        $d['pubdate'] = strtotime($twit->pubDate);
        $d['guid'] = stripslashes(htmlentities($twit->guid,ENT_QUOTES,'UTF-8'));
        $d['link'] = stripslashes(htmlentities($twit->link,ENT_QUOTES,'UTF-8'));
        $twitterPosts[]=$d;
    }
    
    if(is_array($twitterPosts)){
        echo '<ul>';
        foreach($twitterPosts as $post){
    
            if(preg_match($reg_exUrl, $post['description'], $url)) {
                $post['description']=preg_replace($reg_exUrl, "<a href={$url[0]}>{$url[0]}</a> ", $post['description']);
            }
    
            echo '<ul id="twitter_update_list">
                  <li>
        <div id="tweet">'.$post['description'].'<a href="'.$post['link'].'">'.date(' j F',$post['pubdate']).'<br></a></li>';
        }
        echo '</ul>';
    }else{
        echo '<p>Güncel Tweetler Oluşturulamadı Sayfayı Yenilemeyi Deneyin.</p></div>';
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many xml file's, I do not want to get the value, but
I've been trying to use SimpleXML , but it doesn't seem to like XML
I try to make use of the alexa api by amazon. I want to
I asked a similar question last week but did not get an answer that
I use this code for displayig news in my site, but I always get
Welcome all It is possible to use SimpleXML for android in commercial apps? THis
I need an XML parser like SimpleXML, to use in commercial apps. I think
i want to know which parsing method is best to use among Simple XML
use C#,want to upload excel file on google doc. bellow syntax use to upload
I want to do following: Make Oracle stored procedure for read all data from

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.