-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch.php
60 lines (60 loc) · 1.9 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
session_start();
require_once('php-sdk/facebook.php');
$facebook = new Facebook( array(
'appId' => '721823137830217',
'secret' => 'd46d12ee0ee635d6fc3c64ab0e7016d7',
));
$user = $facebook->getUser();
if ($user == 0) {
header('Location: index.php');
}
else {
if (!(isset($_SESSION['loggedin']))) {
header('Location: index.php');
}
}
?>
<html>
<head>
<title>Header</title>
</head>
<body>
<?php
if ($user != 0) {
try {
$user_profile = $facebook->api('/me','GET');
echo "<img src='" . "http://graph.facebook.com/" . $user . "/picture?type=large'>";
echo "<br></br>";
echo "Name: " . $user_profile['name']. "\n";
echo "<br></br>";
echo "Facebook ID: " . $user . "\n";
echo "<br></br>";
$params = array( 'next' => 'http://ec2-54-245-17-195.us-west-2.compute.amazonaws.com/logout.php');
$logoutURL = $facebook->getLogoutUrl($params);
echo '<a href="' . $logoutURL . '">Log-Out</a>';
}
catch(Exception $e) {
echo "Error occurred.";
$facebook->destroySession();
}
$user_profile1 = $facebook->api('/me/friends?fields=name,birthday','GET');
#print_r($user_profile1);
$friends_data = $user_profile1['data'];
$friend_name = $_POST['name'];
$updated_friends_data = array_filter($friends_data, function($var) use ($friend_name) {
return preg_match("/\b$friend_name\b/i", $var['name']);
});
echo "<form action='results.php' method='post'>";
foreach ($updated_friends_data as $friend) {
echo "<input type='checkbox' name='id' value='".$friend['id']."'>".$friend['name']."<br>";
}
echo "<input type='submit'>";
echo "</form>";
}
else {
echo "Something went wrong.";
}
?>
</body>
</html>