Created
October 9, 2012 06:19
-
-
Save brunoamaral/3856956 to your computer and use it in GitHub Desktop.
Facebook SDK example : saving user data to 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
<?php | |
function facebooklog(){ | |
require('/PATH_TO_FACEBOOK_PHP_SDK/src/facebook.php'); | |
$facebook = new Facebook(array( | |
'appId' => 'YOUR_APP_ID', | |
'secret' => 'YOUR_APP_SECRET', | |
)); | |
// Get User ID | |
$user = $facebook->getUser(); | |
if ($user) { | |
try { | |
$user_profile = $facebook->api('/me'); | |
$url = $_SERVER['REQUEST_URI']; | |
$file = 'b_facebook.txt'; | |
$current = file_get_contents($file); | |
$current .= date(r) . ";" . $user_profile[name] . ";" . $url . "\n"; | |
file_put_contents($file, $current); | |
} catch (FacebookApiException $e) { | |
$user = null; | |
} | |
} else { | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment