Home
Username:
Password:
Facebook Application Development Tutorials

Using News Feeds / Testing the Add




Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.


Learn More

Subtitles of the Movie

OK, I'm going to create a new pick now and run that new code that I have in add pick. I'll enter the name of a pick and I'm not going to bother filling in the rest of the data here because I just want to see if this feed is going to work. So I will add the pick. We're adding it to the main database. We are also executing that little chunk of code that will build the feed and I'm going into Add Remove My Pick so that I have it on my list of my picks automatically after I have added it to the main database. And in fact that was the chunk of code that makes it possible; see, here it is ABC Test, it's on my picks, that little chunk of code is what made it possible for me to so easily add the news feed because as soon as I added that record, I immediately retrieved it by name in order to get the ID of the record I had added. The ID of the record was going into Add Remove My Picks and it also goes into the pick ID for the news feed. Now, before we're finished we have to make a couple of adjustments in Browse.php. OK, here we are in browse picks and this has the same structure as all of the other files, my picks, friend's picks and so forth and I'm unloading the parameters that are passed in when this file is called. Most of the time these are the parameters that are used for pagination. Which row do I start retrieving when I do the retrieve for this specific page? Most of the time nothing is passed in for the first called except the base URL if I want to have pagination. I don't have any of these other values so I have not yet had pick id passed in. I've added pick ID so that if it is passed into browse picks, then I will go and retrieve that specific pick ID. The rest of the code is in here but we haven't unloaded it from the request before. So if I come down you'll see here that I need to put pick ID into a local variable from the Array where I've unloaded it and this is the Array of params that's going to be passed in to get from database and render. What I had to do is check and see if pick ID is set, that means I want to retrieve one specific pick; only one. So instead of saying browse, I want to say one and I will pass in the parameters and I will get that individual pick. So I've just added this if statement down here and the choice that if pick ID is passed in, that's what I will get. Browse picks was set up in the beginning to be able to handle retrieving just one pick and you'll see there are some other tricks that has up its sleeve. We have other choices that we can play on. So browse picks is now done and we have to make it match Lib.php. There's a couple of minor changes that we need over in Lib.php to make everything work here. In get from database and render, we have this big switch statement with cases here and we have this case called One which is already set up and it's designed to handle the case that we are calling now of getting one ID. The only thing that we have to do is we have to make certain that we are unloading the pick ID from the parameters Array that is passed in and here's the code to do that. So everything is now in place and that link in my news feed should now be working. Let's take a look at it. I'm looking at my Wall in my profile and lo and behold I have added this news item, I've added, I've picked up the name of the pick that I entered, ABC Test, on Main Street Picks. I can comment on it. I can say I like it, I don't like it and I can find more information. This is that last thing that we added, the action link, that has the link to the specific pick that was just added. I click on Find More Info. You can see up here I'm going to browse picks with the id number of the pick that I'm using and I come in here and we'll go back and complete the cycle we have here. We could select other data but here's ABC Test and the minimum location that I entered. So now we have, let me go back to my profile. What we have here is the ability to create news stories, simple stories that can appear in my news feed and in my friends' news feeds and there are links in them so that people can see what I'm doing and can comment on them and find more information about what I'm doing. This is a critical part of Facebook. It's one of the ways to integrate with Facebook itself and let the people using your apps interact with their friends. In wording the stories that are going to appear here, you should make them as specific and interesting as possible so the people have an idea what's going on.

Tutorial Information

Course: Facebook Application Development
Author: Jesse Feiler
SKU: 34058
ISBN: 1-935320-81-5
Release Date: 2009-11-23
Duration: 7.5 hrs / 92 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available