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.

How to Build a Social News Feed with PHP

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.

Add Comment

Discussion 23 Comments

    • ossama says:

      yeah!! we need a demo please

    • Kimberly says:

      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 says:

        You have some php errors…

      • Kimberly says:

        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!).

    • Joby Joseph says:

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

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

  1. eric says:

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

    MORE PHP

  2. rob says:

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

  3. George Dina says:

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

  4. Jack says:

    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?

  5. Christian says:

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

  6. Alvaro says:

    Is this for sale at the tuts+ marketplace?

  7. Kimberly says:

    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

  8. Vishnu says:

    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 says:

      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?

  9. momen says:

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

    plz help i want this tutorial Any way

  10. 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.

  11. mark says:

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

  12. aoiTo says:

    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!

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.