Все что после 111 затирается.
Получается ?text1=111&code=AQCgO7...
Может кто сталкивался? Подскажите пожалуйста как поправить?
class FBAuth{
public $settings = array();
public $auth_status = false;
public $user_info = array();
public function __construct($settings){
if(isset($settings["client_id"], $settings["client_secret"], $settings["redirect_uri"])){
$this->settings = $settings;
}
}
public function auth($code){
if($code && $this->settings){
$query = urldecode(http_build_query(array(
"client_id" => $this->settings["client_id"],
"redirect_uri" => $this->settings["redirect_uri"],
"client_secret" => $this->settings["client_secret"],
"code" => $code
)));
$token = json_decode(file_get_contents("https://graph.facebook.com/oauth/access_token?".$query), true);
if(isset($token["access_token"])){
$query = urldecode(http_build_query(array(
"access_token" => $token["access_token"],
"fields" => "id,first_name,gender,last_name,picture.width(120).height(120)"
)));
$this->user_info = json_decode(file_get_contents("https://graph.facebook.com/me?".$query), true);
if(isset($this->user_info["id"])){
$this->auth_status = true;
return true;
}
}
}
return false;
}
public function get_link(){
if($this->settings){
$query = urldecode(http_build_query(array(
"client_id" => $this->settings["client_id"],
"redirect_uri" => $this->settings["redirect_uri"],
"response_type" => "code"
)));
return "https://www.facebook.com/dialog/oauth?".$query;
}
return false;
}
}
$fb = new FBAuth(array(
"client_id" => "210294365989709",
"client_secret" => "75deae4d4b290157bf8bf2631a88b6ce",
"redirect_uri" => "http://site.ru/test1/?text1=111&text2=222&text3=333"
));
if(isset($_GET["code"])){
if($fb->auth($_GET["code"])){}
}
if($fb->auth_status){
echo("ID пользователя: ".$fb->user_info["id"]);
}else{
echo("<a href='".$fb->get_link()."'>Войти</a>");
}