SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    730
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Publishing Tweets On A Page

    Hi,

    I am trying to publish Tweets onto a page. Does anyone know how it can be done?

    I have the following code but it doesn't work.


    Code:
    		<div class="twittercellwhyev">
    <ol>
    <?	
    
    $feed = json_decode(file_get_contents('https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=bbc&count=5'));
    
    
    $pattern = "/http:\/\/(www\.)?([^.]+\.[^.\s]+\.?[^.\s]*)/i";
    $replace = "<a href='http://\\1\\2'>http://\\1\\2</a>";
    
    foreach($feed as $output) {
    
    ?>
    	<div class="twittercellinnerev">
    	<li>
    <?	
    echo preg_replace($pattern,$replace,$output->text);
    ?>
    	</div>
    	</li>
    <?	
    
    }
    ?>
    </ol>
    	<div class="twitterwhyevimage">
    	<a href="http://twitter.com"  rel="nofollow" >
    <img src="/images/followusontwitter.png" alt="Twitter.com"/>
    </a>
    	</div>	
    	</div>

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could look at

    http://www.webtribe.com.au/blog/2011...ding-retweets/

    This does it via javascript rather than server side.

  3. #3
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    730
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanks mate, that worked fine.

  4. #4
    Community Advisor ULTiMATE's Avatar
    Join Date
    Aug 2003
    Location
    Bristol, United Kingdom
    Posts
    2,158
    Mentioned
    45 Post(s)
    Tagged
    0 Thread(s)
    As a note for anyone looking at this from a Google search, it is worth looking at the Twitter API to see if these methods have been superseded by the new version of the API.

  5. #5
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,576
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    ^^^^ this. Anonymous search is going away and twitter is killing any 3rd party widget it can. Still waiting on guidance as to how to do this come March.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •