我正在尝试将 facebook 登录整合到我的网站,我得到的错误是:
array_merge() [function.array-merge]: Argument #2 is not an array
Filename: fb/base_facebook.php
Line Number: 529
我在控制器中使用的代码是:
$this->load->library('fb');
$data = array
(
'redirect_uri'=>site_url('main/handle_facebook_login'),
'scope'=>'email'
);
$this->fb->sdk->getLoginUrl('$data');
getLoginUrl 是它抛出豁免的地方
fb库中的代码是:
class Fb {
private $appid = '';
private $secret = '';
public function __construct()
{
$ci =& get_instance();
$ci->config->load('fb');
$this->appid = $ci->config->item('fb_appid');
$this->secret = $ci->config->item('fb_secret');
//load the library
$this->load();
}
private function load()
{
include_once 'fb/facebook.php';
$credentials = array(
'appId' => $this->appid,
'secret' => $this->secret
);
$this->sdk = new Facebook($credentials);
}
}
我将其传递给的 base_facebook 中的代码是:
/**
* Get a Login URL for use with redirects. By default, full page redirect is
* assumed. If you are using the generated URL with a window.open() call in
* JavaScript, you can pass in display=popup as part of the $params.
*
* The parameters:
* - redirect_uri: the url to go to after a successful login
* - scope: comma separated list of requested extended perms
*
* @param array $params Provide custom parameters
* @return string The URL for the login flow
*/
public function getLoginUrl($params=array()) {
$this->establishCSRFTokenState();
$currentUrl = $this->getCurrentUrl();
// if 'scope' is passed as an array, convert to comma separated list
$scopeParams = isset($params['scope']) ? $params['scope'] : null;
if ($scopeParams && is_array($scopeParams)) {
$params['scope'] = implode(',', $scopeParams);
}
return $this->getUrl(
'www',
'dialog/oauth',
array_merge(array(
'client_id' => $this->getAppId(),
'redirect_uri' => $currentUrl, // possibly overwritten
'state' => $this->state),
$params));
}
我不明白我做错了什么,我正在传递一个数组,但它说我不是?有人可以帮忙吗?