Facebook访问令牌“;您正在使用不兼容的web浏览器“;使用php


Facebook access token "You are using an incompatible web browser" with php

我试图用我的(创建中的)facebook类从facebook获得访问令牌。但它告诉我,我有一个"你正在使用一个不兼容的网络浏览器"。我怎样才能通过这个错误?我试图设置http_user_agent,但它不起作用。

谢谢你的帮助!

介于两者之间,我不想要facebook sdk,我想了解我所做的一切。这可能吗?

$_COOKIE['evo-fbAuth']=false;$_SERVER['HTTP_USER_AGENT']="Mozilla/5.0(Windows NT 5.1;rv:10.0.2)Gecko/20100101 Firefox/10.0.2";班级facebook{private$_appID;私人$_appSECRET;private$_code=null;private$_accesstoken=null;private$_urlAuth='https://www.facebook.com/dialog/oauth';函数__construct($appID,$appSECRET){$this->_appID=$appID;$this->_appSECRET=$appSECRET;}公共函数fbauth($param){if(!isset($_GET['code'])){if(isset($param['direct_uri'])&&isset($param['scope'])){$urlAuth=$this->_urlAuth;$urlAuth.='?client_id='$this->_appID;$param['redirect_uri']=$param['redirect_uri'];foreach($param as$key=>$value){$urlAuth.='&'$键。'='$价值}if(!$this->authCookie())标头('位置:'.$urlAuth);}其他{return false;}}其他{$this->_code=$_GET["代码"];$this->getAccessTok($param);}}私有函数getAccessTok($param){if($this->_code!==null){$urlTok=$this->_urlAuth.'/access_token';$urlTok.='?client_id='$this->_appID;$urlTok.='&redirect_uri='$param['direct_uri'];$urlTok.='&client_secret='$this->_appSECRET;$urlTok.='&code='$this->_code;print_r(file_get_contents($urlTok));}}私有函数authCookie(){if($_COOKIE['evo-fbAuth']==true){返回true;}其他{setcookie('vo-fbAuth',true,600);return false;}}}$fb=新的facebook('**************','****************************');$param=数组('redirect_uri'=>'http://localhost/facebook-auth/MOI_facebook.class.php','scope'=>'read_stream,publish_stream、publish_actions、manage_pages、电子邮件、user_birthday');$fb->fbauth($param);

这是因为您在getAccessTok函数中使用了错误的URL进行access_token检索

// URL you use is $this->_urlAuth.'/access_token'
https://www.facebook.com/dialog/oauth/access_token
// But should be
https://graph.facebook.com/oauth/access_token