Skip to content

Instantly share code, notes, and snippets.

@nguyenphucbao68
Last active April 18, 2018 14:01
Show Gist options
  • Save nguyenphucbao68/6612602bf3a3c1fdc4a1c0ea8520f8d4 to your computer and use it in GitHub Desktop.
Save nguyenphucbao68/6612602bf3a3c1fdc4a1c0ea8520f8d4 to your computer and use it in GitHub Desktop.
Script Get Fbid From UserName - PHP - Jack098
<?php
/**
* GET FBID FROM LINK USERNAME
* Author : fb.com/trojan.nguyen.103
* Blog : https://jack098.blogspot.com
*/
header("Access-Control-Allow-Origin: *"); //bắt buộc - thông số để get được Json cho APP - tham khảo : https://goo.gl/ox3gf3
class getFbid
{
function __construct($Array)
{
if(isset($Array["username"], $Array["access_token"])) {
$this->LinkUserName = $Array["username"];
$this->access_token = $Array["access_token"];
}
}
public function get()
{
# Get Fbid
$link = json_decode(file_get_contents('https://graph.facebook.com/'.$this->LinkUserName.'?fields=id&access_token='.$this->access_token));
$array = array(
'fbid' => $link->id //Get ID
);
return $array;
}
public function OutputJson($Array)
{
# Export Json
if(!is_array($Array)) die(0);
echo json_encode($Array);
}
}
if(isset($_GET["link"]) && filter_var($_GET["link"], FILTER_VALIDATE_URL)){
$LinkUserName = array(
'username' => $_GET["link"],
'access_token' => 'Token của bạn'
);
$getFbid = new getFbid($LinkUserName);
$getFbid->OutputJson($getFbid->get());
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment