Permalink
Browse files

Added comments to code.

  • Loading branch information...
1 parent 1d6619c commit ab91fd09af03d52b22f40e0a27e8888ca0334a3c @kduncan kduncan committed May 12, 2010
Showing with 9 additions and 0 deletions.
  1. +9 −0 index.php
View
@@ -10,21 +10,30 @@
$facebook->require_frame();
$user = $facebook->require_login();
+//retrieve the logged in users first name, last name and email address
$user_details = $facebook->api_client->users_getInfo($user, "first_name, last_name, email");
+//check to make sure facebook returns values
+
if (!is_array($user_details)) {
$data["email"] = '';
$data["first_name"] = '';
$data["last_name"] = '';
}
+
+//if facebook returns values then create php variables for returned data
else {
$emails = $data["email"] = $user_details[0]["email"];
$first_name = $data["first_name"] = $user_details[0]["first_name"];
$last_name = $data["last_name"] = $user_details[0]["last_name"];
}
+//connect to your database
@Africalifornia
Africalifornia Apr 5, 2011

you should write your own database infos here.

$mysqli = mysqli_connect ("localhost", "username", "password", "database");
+
+//run sql query to insert php variables into your database
$sql = "INSERT INTO [[YOUR TABLE]] (email_address, first_name, last_name) VALUES ('$emails', '$first_name', '$last_name')";
$res = mysqli_query($mysqli, $sql);
+//close database connection
mysqli_close($mysqli);

0 comments on commit ab91fd0

Please sign in to comment.