How to Build a Social News Feed with PHP: New on Premium
plusvideos

How to Build a Social News Feed with PHP: New on Premium

Tutorial Details
  • Topic: PHP
  • Difficulty: Intermediate
  • Availability: Premium Exclusive
Download Source Files

There are numerous ways to display Twitter and Facebook posts on your website, but many of them lack the ability to customize the look and feel of that information. This Premium tutorial screencast will demonstrate how to retrieve the raw data from both social media giants and combine them into one feed to use on your website.

Become a Premium member to read this tutorial, as well as hundreds of other advanced tutorials and screencasts.

Join Net Premium

NETTUTS+ Screencasts and Bonus Tutorials

For those unfamiliar, the family of Tuts+ sites runs a premium membership service. For $19 per month, you gain access to exclusive premium tutorials, screencasts, and freebies from Nettuts+, Psdtuts+, Aetuts+, Audiotuts+, Vectortuts+, and CgTuts+ For the price of a pizza, you’ll learn from some of the best minds in the business. Become a Premium member to read this tutorial, as well as hundreds of other advanced tutorials and screencasts.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://laranzjoe.blogspot.com lawrence77

    Any demos?

    • http://twitter.com/ossamaweb ossama

      yeah!! we need a demo please

    • http://www.kimberlyhogg.com Kimberly

      If you’re looking for a demo, you can check out my result after completing the tutorial. It’s pretty much exactly what he creates.

      http://www.kimberlyhogg.com/playground/socialfeed/

      • JohnJohn

        You have some php errors…

      • http://www.kimberlyhogg.com Kimberly

        Thanks JohnJohn. This was due to me changing my Facebook access token. I have updated it on the page. If you ever need to generate a new access token, you can go to: https://developers.facebook.com/tools/explorer .

        A few more items to prevent PHP errors that I learned while modifying the source of this tutorial to create a newsfeed in the footer on my personal site:

        At the top of the php file, it is helpful to add the line: date_default_timezone_set(“UTC”);
        This prevents errors when using the strtotime function.

        If your Facebook password changes, you need to re-retrieve authentication for the access token via the link I mentioned earlier.

        While not really an error, once you begin to add feeds from three or more sources, it gets complicated to combine the data feeds as is done in the tutorial. A cleaner approach is to do an array_merge for each of the feeds, then use array_multisort to order by date, before grabbing the first 5 (or however many) items in the array.

        Thanks again to the author of this tutorial. I feel like this is possibly the most useful tutorial on this site (which is saying a lot!).

    • http://www.jobyj.in Joby Joseph

      How to Authenticate Users using Official Facebook PHP SDK. Demo and Source Code available.

      http://jobyj.in/api/facebook-authentication-using-php-sdk/

  • eric

    I’m sorry but that was f*#%(@g! awesome!!!!!

    MORE PHP

  • rob

    good one. maybe one day php.tutsplus.com? :)

  • http://www.georgedina.info George Dina

    I am sure this is awesome.
    I think I will buy a premium account.

  • Jack

    Would this Tut be too advanced for somebody new to PHP?
    I have only ever used PHP for includes in the past, would I be out of my depth?

    • http://newarts.at Drazen Mokic

      If you are totally new it might be hard

  • http://tutorials.aratide.com Brad

    Very Nice!

  • http://pangomedia.se Christian

    Great tutorial!
    How are you working online with TextMate directly like that?

    • http://kaischaller.com Kai Schaller
      Author

      Thanks, Christian. I’m using the “Mount as Disk” feature in Transmit 4, so when I save the file it’s automatically uploaded to the server.

  • http://www.southmakers.com Alvaro

    Is this for sale at the tuts+ marketplace?

    • http://www.southmakers.com Alvaro

      Nevermind, just found it, purchasing!

  • http://www.kimberlyhogg.com Kimberly

    Wow this tutorial was wonderful and exactly what I was looking for.

    I did find a somewhat simpler way to acquire an access token for my Facebook page though.
    If you go to https://developers.facebook.com/tools/explorer , you can generate a token for whatever content you are looking to access. However, I never knew how to do any of that before this tutorial.

    Great job and thank you so much!

    -K

  • Vishnu

    Warning: DOMDocument::load(http://twitter.com/statuses/user_timeline/249089124.rss) [domdocument.load]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
    in C:\wamp\www\emcaned\social.php on line 12

    When I tried to run the script on localhost I got an error like this…. I used domdocument object instead of simplexml….

    • Vishnu

      When I tried to open the rss feed in browser this was the result:

      Rate limit exceeded. Clients may not make more than 150 requests per hour.
      /statuses/user_timeline/249089124.rss

      Can anyone help?

  • momen

    hey
    i want buy this video
    but i cant becouse
    i am from egypt

    plz help i want this tutorial Any way

  • http://www.pinchecom.com Art Rodriguez

    Hi, this tutorial is great. Learned so much following the video. The only problem i found is that when I visit the url https://graph.facebook.com/USERID/feed?access_token=MYTOKEN, the ‘message’ field is not present. All the other data and fields are there, but the ‘message’ field isn’t. I’m referring to the part you go over at 20:15 in the video. When I launch the my site, I receive the following message:

    Notice: Undefined property: stdClass::$message in ../socialmedia/index.php on line 37

    I’m not sure if Facebook changed something to no longer make the ‘message’ field visible. Please advise if you ran into this issue.

  • mark

    HI I am making blog about PHP & MySQL from basis to social networks etc… the link is here :
    http://phpandmysqldev.blogspot.com/

  • aoiTo

    First, apologize for my English.

    You will see, I am making a website and would like it on the footer. I’ve been reading about how to do this and there are several ways.

    Reading the documentation for twitter, using this URL would get messages from the user ( http://api.twitter.com/1/statuses/user_timeline/{usuario}.json?count=3&include_rts=1&include_entities=true&callback={callback function} ). I can think of several ways to display these messages on my site:

    · HTML5: using async and defer attributes and Javascript.
    · Using jQuery and Ajax.
    · Using PHP but reading the URL as XML and not JSON (CURL or simplexml_load_file).

    But my question is, how I can do this without affecting the loading speed of my site? I would like to know the fastest way to do it without affecting the loading speed of the web.

    Thank you so much!