-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7b94f73
Showing
9 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
conf.php | ||
*~ | ||
php-sdk |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
function getUser($facebook) { | ||
$user=$facebook->getUser(); | ||
if($user) { | ||
//$user_profile = $facebook->api('/me'); | ||
//echo "<pre>";print_r($user_profile);echo"</pre>"; | ||
return $user; | ||
} | ||
else { | ||
$params = array("scope" => "email", "redirect_uri" => "http://apps.facebook.com/ram_test_run/"); | ||
$loginUrl = $facebook->getLoginUrl($params); | ||
echo "<script> top.location.href='".$loginUrl."';</script>"; | ||
} | ||
} | ||
|
||
function runFql($facebook,$query) | ||
{ | ||
try | ||
{ | ||
$result = $facebook->api(array('method' => 'fql.query', 'query' => $query)); | ||
} | ||
catch (\Exception $e) | ||
{ | ||
print_r($e->getMessage()); | ||
return false; | ||
} | ||
return $result; | ||
} | ||
|
||
function deleteRequestFromFB($req_id, $app_access_token) | ||
{ | ||
$delete_url = "https://graph.facebook.com/" . $req_id. "?access_token=" . $app_access_token . "&method=delete"; | ||
$fb_result = self::requestFacebook($delete_url); | ||
if(isset($fb_result)) | ||
{ | ||
return $fb_result; | ||
} | ||
return false; | ||
} | ||
|
||
function sendAppRequest($to_uid, $message, $app_access_token) | ||
{ | ||
$apprequest_url = "https://graph.facebook.com/$to_uid/apprequests?message=" . urlencode($message) . "&access_token=$app_access_token&method=post" ; | ||
$fb_result = self::requestFacebook($apprequest_url); | ||
$result = json_decode($fb_result, true); | ||
if(isset($result['request']) && $result['to'][0] == $to_uid) | ||
{ | ||
return $fb_result; | ||
} | ||
return false; | ||
} | ||
|
||
function getFriends($facebook,$uid) | ||
{ | ||
$friends = $facebook->api('/'.$uid.'/friends'); | ||
return $friends['data']; | ||
} | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
function postToFeed() { | ||
|
||
// calling the API ... | ||
var obj = { | ||
method: 'feed', | ||
link: 'https://developers.facebook.com/docs/reference/dialogs/', | ||
picture: 'http://fbrell.com/f8.jpg', | ||
name: 'I won this', | ||
caption: 'This is a subtitle', | ||
description: 'I won this wonderful award. You should click and see the award' | ||
}; | ||
|
||
function callback(response) { | ||
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id']; | ||
} | ||
|
||
FB.ui(obj, callback); | ||
} | ||
|
||
|
||
function sendRequest() { | ||
FB.ui({method: 'apprequests', | ||
message: 'My Great Request', | ||
to: "", | ||
}, null); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div id="fb-root"></div> | ||
<script src="//connect.facebook.net/en_US/all.js" type="text/javascript"></script> | ||
<script type="text/javascript"> | ||
FB.init({appId: "<?php echo APPID;?>", status: true, cookie: true, xfbml:true}); | ||
</script> | ||
<script src="code.js" type="text/javascript"></script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
require_once("conf.php"); | ||
require_once("Utils.php"); | ||
require_once("header.html"); | ||
|
||
$user = getUser($facebook); | ||
|
||
echo $user; | ||
$email = runFql($facebook,"SELECT email from user where uid=$user"); | ||
echo $email[0]['email']; | ||
|
||
$friends = $facebook->api('/me/friends'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="header" style="position:relative;padding: 10px;background-color:#C3CDDF;"> | ||
<h2 style="float:left;">My App</h2> | ||
<div style="float:right;"> | ||
<img src="http://graph.facebook.com/<?php echo $user; ?>/picture"></img> <br/> | ||
<fb:name useyou="false" uid="<?php echo $user; ?>"></fb:name> | ||
</div> | ||
<div style="clear:both;"></div> | ||
</div> | ||
|
||
<div class="content"> | ||
<h3> Friends </h3> | ||
<ul> | ||
<?php foreach ($friends as $key=>$value) { ?> | ||
<li> | ||
<img src="http://graph.facebook.com/<?php echo $value['id']; ?>/picture"></img> | ||
<?php echo $value['name']; ?> | ||
</li> | ||
<?php } ?> | ||
</ul> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
require_once("conf.php"); | ||
require_once("Utils.php"); | ||
require_once("header.html"); | ||
|
||
$user = getUser($facebook); | ||
$friends = getFriends($facebook,$user); | ||
//print_r($friends); | ||
require_once("run.html"); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
define('APPID','Your APP ID'); | ||
define('APPSECRET','APP SECRET'); | ||
|
||
$fb_sdk_path = __DIR__."/php-sdk/src"; | ||
set_include_path(get_include_path() . PATH_SEPARATOR . $fb_sdk_path); | ||
require_once("facebook.php"); | ||
|
||
|
||
|
||
$facebook = new Facebook(array( | ||
'appId' => APPID, | ||
'secret' => APPSECRET, | ||
)); | ||
|
||
?> |