Saturday, November 10, 2012

Search People Using Pipl API



If you are a Facebook user or Twitter user like me, you already know how to find a particular person. Facebook Friends Finder is a great tool. It is so intelligent that it can find mutual relationships and many more. Several weeks ago, I wanted some methodology to develop a web solution to allow someone to find his interested people. It should not be limited to Facebook. The user may wish to see search results from different social networks. Obviously, it 's very difficult to integrate several social networks and develop a combined solution. The easiest way is to find a good API that provides reliable information. There comes Pipl. It 's highly sophisticated.

So you know what I gonna explore today. The Pipl Search API. This is a Restful API that can generate response in xml as well as json format for a given user information. There are huge amount of query parameters. You can use any of them as you wish. In this tutorial, I show you how to find a person when we know his first name and last name. Very simple. Just a matter of decoding json/xml response.

HTML Form

[sourcecode language="html"]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>
<form method="get">
First <input name="first" type="text" value="asantha">
Last <input name="last" type="text" value="prasad">
<input name="btn" type="submit">
</form>
</body>
</html>
[/sourcecode]

PHP Script

[sourcecode language="php"]

if(isset($_GET['first']) && isset($_GET['last']))
{
$first = $_GET['first'];
$last = $_GET['last'];</pre>
$json = file_get_contents("http://apis.pipl.com/search/v2/json/?first_name=$first&last_name=$last&key=h6cbvuu8mkj97vbrztanvptp");

$json_o = json_decode($json);

$count = 0;
foreach($json_o->results->records as $rec)
{
echo ++$count." ".$rec->names[0]->display ."<br>";
echo "Domain : " .$rec->source->domain."<br>";

$url =  $rec->source->url;
echo "<a href='$url'>URL</a><br>";

$img =  $rec->images[0]->url;
echo "<img src='$img' width='125px' height='125px'>";
echo "<hr><br>";
}

echo "<hr><h3>suggestions</h3>";
$suggest =  $json_o->suggested_searches[0]->source->url."h6cbvuu8mkj97vbrztanvptp";
echo "<a href='$suggest'>visit</a>";
}

[/sourcecode]

No comments:

Post a Comment

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...