I use facebook api to get facebook user id and then paste it into mysql. It works great for the most part. But for some strange reason, the value that is inserted into the fb_id column in my db is different from the value that is supposed to be inserted into the query string. My code is as follows:
$facebook = new Facebook(array( 'appId' => '12345', 'secret' => '12345', 'cookie' => true )); $access_token = $facebook->getAccessToken(); if($access_token != "") { $user = $facebook->getUser(); if($user != 0) { $user_profile = $facebook->api('/me'); $fb_id = $user_profile['id']; $fb_first_name = $user_profile['first_name']; $fb_last_name $user_profile['last_name']; $fb_email = $user_profile['email']; $img_data = file_get_contents('https://graph.facebook.com/'.$fb_id.'/picture?type=large'); $save_path = 'img/profile_pics/large/'; file_put_contents(''.$save_path.''.$fb_id.'.jpg', $img_data); $insert = "INSERT INTO users (first_name, last_name, email, photo, fb_id, accuracy_rate, date_joined, date_joined_int) VALUES ('".$fb_first_name."', '".$fb_last_name."', '".$fb_email."', '".$fb_id.".jpg', '".$fb_id."', '100', '".date("F j, Y")."', '".idate("z")."')"; $result = mysql_query($insert)or die(mysql_error()); } }
The value that is inserted into the database is "2147483647". The correct value should be "100000034641562". It is strange that in the column under the name "photo" the value equal to ". $ Fb_id." Should be indicated. Jpg ". Basically, the facebook id is just with" .jpg "at the end. This column has the correct value inserted into it (100000034641562.jpg). But there is no fb_id column. I thought I might have to adjust the sorting for the length column, but that is not a problem.
Any ideas?
Thanks,
A spear
Lance source share