Building services like FriendFeed using PHP - Part2

Posted on June 3, 2008
Filed Under Tutorial, Web Services | Leave a Comment

By Hasin Hayder

Following the first installment in this series, here is the second part. In this part I will focus mainly on Bookmarking and News services supported by FriendFeed . Here we go

Supported bookmarking services by FriendFeed
1. Del.icio.us
2. Furl
3. Google shared stuffs
4. Mag.nolia
5. Stumbleupon

Except google shared stufss, all of the rests require just an username to generate the access point for retrieving user’s bookmarked items. And for the google shared stuffs, it requires the fully functional url of the feed available from your google bookmark service.

Access points

Del.icio.us

AP: http://feeds.delicious.com/rss/<user name>
example: http://feeds.delicious.com/rss/anduh


FurlAP: http://rss.furl.net/member/<user name>.rss;
example: http://rss.furl.net/member/pigge.rss


Google Shared Stuffs
you can find your google shared stuff url from http://www.google.com/s2/sharing/stuffexample: http://www.google.com/s2/sharing/stuff?user=110703083499686157981&output=rss


Ma.gnoliaAP: http://ma.gnolia.com/rss/lite/people/<user name>.rss;
example: http://ma.gnolia.com/rss/lite/people/gerryquach


Stumbleupon
Whoops, Double Whoops, Tripple Whoops. It took quite a time for me to find the feed url. I dont know why it is kept so “SECRET” - LOLAP: http://www.stumbleupon.com/syndicate.php?stumbler=<user name>.rss;
example: http://www.stumbleupon.com/syndicate.php?stumbler=jd001


Supported news services by FriendFeed
1. Digg
2. Google Reader
3. Mixx
4. Reddit

Here are the access points


DiggAP: http://digg.com/users/<user name>/history.rss;
example: http://digg.com/users/msaleem/history.rss


Google ReaderYou can find your shared item’s feed url here http://www.google.com/reader/view/user/-/state/com.google/broadcast


MixxUnfortunately during the time of writing this article, Mixx was napping - here is the screenshot. Once they are awake, I will update this section :)


RedditAP: http://www.reddit.com/user/<user name>/.rss;
example: http://www.reddit.com/user/jack_alexander/.rss

In next installation I will focus on scaling such a huge load successfully. Hope that will be interesting to many of you. Following installation will focus again on the access points.

Building services like FriendFeed using PHP - Part 1

Posted on June 3, 2008
Filed Under Web Services | Leave a Comment

By Hasin Hayder

Friendfeed is an excellent life streaming service aggregating all your feeds from different service providers, compile them together, build a social network among your known people and finally deliver all these feeds as a mashup. As a result you can immediately track activities of your friends on all the different service they use (like jaiku, twitter, flickr) and stay up-to-date. Hats off to the developers of FriendFeed for delivering such a nice application to us.

In this blog post I will try to focus on how to develop such a service like Friendfeed using PHP and JS and how to scale such a huge load successfully. Previously I’d also written another article focusing “How to develop services like SpringLoops using PHP“. The complete article will be delivered in multiple installments and in current installment, I will focus on Photo sharing services used by friendfeed.

Area to focus
1. Services to be supported
2. Update discovery
3. Parsing the feeds
4. Storing the data
5. Scaling

FriendFeed parses feeds from a total of 35 popular services from around the web ;) - lets have a look at them one by one and I will give you idea about the access points of these services. Though Not all of them are feed, so I will try to focus those services as well to give you a basic idea.

Service 1 : Flickr
Usable PHP Library: PHPFlickr

Flickr is an excellent photo sharing services under the banner of Yahoo. Friendfeed parses all the photo from a user and also the list of his/her favorite photos. Given an username you can easily find the Flickr ID like (76536911@N00)of that user and once you got it, here is the access points for list of public photos and favorites

List of photos
http://api.flickr.com/services/feeds/photos_public.gne?id=<user’s flickr id>&lang=en-us&format=rss_200
example: http://api.flickr.com/services/feeds/photos_public.gne?id=76536911@N00&lang=en-us&format=rss_200

List of favorites
http://api.flickr.com/services/feeds/photos_faves.gne?nsid=<user’s flickr id>&lang=en-us&format=rss_200
example:http://api.flickr.com/services/feeds/photos_faves.gne?nsid=76536911@N00&lang=en-us&format=rss_200

Service 2: Picasa Web Album
Picasa is another photo sharing service under the banner of the Giant, Google. Given a picasa user name , here are the access point of user’s public photos

List of public photos
http://picasaweb.google.com/data/feed/base/user/<picasa user name>?kind=album&alt=rss&hl=en_US&access=public
example:http://picasaweb.google.com/data/feed/base/user/countdraculla?kind=album&alt=rss&hl=en_US&access=public

Service 3: Smugmug
Here comes another photo sharing service where users can buy and sell their photos. Given a smugmug user name you can find the feed of this user’s photos

List of public photos
http://<smugmug user name>.smugmug.com/hack/feed.mg?Type=nickname&Data=Ifocus&format=rss200
example:http://ifocus.smugmug.com/hack/feed.mg?Type=nickname&Data=Ifocus&format=rss200

Service 4: Zoomr
Zoomr is another photo sharing service started in late 2005 by Kristopher Tate as a place for him to share photos with his friends and later became a public services, is currently supported by FriendFeed. And here we go with the access points :)

List of public photos
http://www.zooomr.com/services/feeds/public_photos/?id=<zoomr user name>&format=rss_200
example:http://www.zooomr.com/services/feeds/public_photos/?id=wolfmank&format=rss_200

In next part, I will highlight the access points of supported bookmark services and news services supported by FriendFeed :) Have a nice weekend.

PHP Unique Hit Counter

Posted on December 22, 2007
Filed Under Access Counters | Leave a Comment

Description

This simple and easy-to-use script logs the number of unique visitors to your web site by logging only one occurence of each IP address. This script is 100% free!
Installation

It’s a quick 3-step process.

1.
Upload uniquehits.php and uniquehits.log to your web server.
2.
CHMOD 666 (writable) uniquehits.log (skip this step on Windows servers).
3.
Insert this PHP code on every page where the counter should appear:

<? include ‘uniquehits.php’ ?>

Done!

DOWNLOAD LINK

Object Oriented PHP Counter

Posted on December 21, 2007
Filed Under Access Counters | Leave a Comment

A more advanced version of our PHP Counter, this script is object oriented and remembers return visitors by setting a cookie. Because it remembers visitors, this counter counts the number of unique visitors that visited your site.

This script is object oriented and written for PHP 5+, which handles object differently than older versions of PHP. Being object oriented allows multiple counters to exists on one page, or on different pages throughout the site. While you can copy this class into each page that you want to use it on, the best way is to include it in its own file at the top of your page. For example:

<?php

include(’counter_script.php’);
$myCounter=new Counter();

//NOW START HTML
?>
<html>

Read more

PHP Login script tutorial

Posted on December 21, 2007
Filed Under Tutorial | 1 Comment

Overview

In this tutorial create 3 files
1. main_login.php
2. checklogin.php
3. login_success.php

Step
1. Create table “members” in database “test”.
2. Create file main_login.php.
3. Create file checklogin.php.
4. Create file login_success.php.
5. Create file logout.php
Read more

server to server file transfar using php script

Posted on December 2, 2007
Filed Under Clients and Servers, File Management | Leave a Comment

Script: Server-to-Server Transfer using PHP
Server to Server Transfer 2 or SST is a PHP class that can be used to move
a file from a server to another.

The moving process occurs by using HTTP protocol (by GET request), after the
data is requested, it will be saved in the local komputer. So to use the SST,
you have to install the script in the target computer where the file will be
moved.

The computer where this script will be installed, should meet this requirements:
1. Using Linux/Windows
2. Have PHP Interpreter version 4 or higher
3. PHP was set to allow Remote File Access
(setting “allow_url_fopen” = true)

Installation
————

1. Copy sst.php, downloader.php and script.inc.php to desired directory
2. Call sst.php using your browser.

Notes
—–
1. The maximum size of file that will be moved is 5*1048576 (5MB)
2. SST 2 now works with “redirection” URL.
3. SST 2 now works with password protected URL.
Read more

Wordpress Theme GX3 Gray

Posted on November 19, 2007
Filed Under Uncategorized, WordPress | Leave a Comment

Live Preview

Download Now

How to create a basic rating system

Posted on October 30, 2007
Filed Under Code Snippets | Leave a Comment

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“DTD/xhtml1-transitional.dtd”>
<html>
<body>
<?php if ( (!isset($_POST[’submit’])) ) { ?>
  <form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>“ method=”post”>
<table>
<tr>
<td>Your rating:</td>
<td><select name=”rate”>
<option value=”1″>1</option>
<option value=”2″>2</option>
<option value=”3″>3</option>
<option value=”4″>4</option>
<option value=”5″>5</option>
</select></td>
</tr>
<tr><td colspan=”2″ align=”center”>
<input type=”submit” value=”Rate it!” name=”submit”/>
</td></tr>
</table>
</form>

<?php
} else  {
$rate = isset ($_POST[‘rate’]) ? $_POST[‘rate’] : 0;
$filename     “ratings”;
$alreadyRated false;
$totalRates   0;
$totalPoints  0;

$ip getenv(‘REMOTE_ADDR’);

// Read the result file
$oldResults file(‘results/’.$filename.‘.txt’);

// Summarize total points and rates
foreach ($oldResults as $value) {
$oneRate explode(‘:’,$value);
// If our IP is in the list then set the falg
if ($ip == $oneRate[0]) $alreadyRated true;
$totalRates++;
$totalPoints += $oneRate[1];
}

// If our rating is valid then append it to the result file
if ((!$alreadyRated) && ($rate 0)){
$f fopen(‘results/’.$filename.“.txt”,“a+”);
fwrite($f,$ip.‘:’.$rate.“\n”);
fclose($f);
$totalRates++;
$totalPoints+=$rate;
}

echo “Actual rating from $totalRates rates is: ”
.substr(($totalPoints/$totalRates),0,3).“<br/>”;

// Display the actual rating
for ($i=0;$i<round(($totalPoints/$totalRates),0);$i++){
echo 
“<img src=’style/star.png’ />”;
}
?>
</body>

Code Snippet: Date converter

Posted on October 16, 2007
Filed Under Code Snippets | Leave a Comment

Snippet: Date converter

Description:

This tiny piece of code takes care that you can display a standard date instead of the mysql date (2005-02-23)

Example:
echo date(”d m Y”, “2005-02-23″);

Shows:
23 02 2005

Code:
PHP:
Read more

Snippet: Are sessions working?

Posted on October 16, 2007
Filed Under Code Snippets | Leave a Comment

Description:

You can use this piece of code to check if it is possible to use sessions for the visitor.

This can come handy for login pages. If you have cookies disabled and try to login, no login session can be used. In such cases it is nice to inform your visitors.

Code:
PHP:



<?php

session_start ();
//Check GET request
if (isset ($_GET[‘cookie_check’])){
//Check session
if (isset ($_SESSION[’session_set’])){
//Display working message
echo “working…”;
exit;
//Or redirect
//header (”Location: cookie_working.php”);
} else {
//Display failure message
echo “failure…”;
exit;
//Or redirect
//header (”Location: cookie_fail.php”);
}
}
session_register (“session_set”);
$_SESSION[’session_set’] = true;
header (“Location: cookie_check.php?cookie_check=1″);

?>

keep looking »