我的网站中有 Facebook 应用程序。当我们集成 Facebook 时,它每次都会导致 facebook 登录页面,但我想从 mysite 登录 facebook。我将为 facebook 提供单独的登录表单,当我们在 mysite login 中输入 facebook 凭据时,它将登录到 facebook 而无需询问 facebook 登录页面。有可能吗?我尝试了以下 curl 功能但没有成功
<?php
$EMAIL = "fb_user_email";
$PASSWORD = "password";
function cURL($url, $header=NULL, $cookie=NULL, $p=NULL)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_NOBODY, $header);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if ($p) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
}
$result = curl_exec($ch);
if ($result) {
return $result;
}
else {
return curl_error($ch);
}
curl_close($ch);
}
$a = cURL("https://login.facebook.com/login.php?login_attempt=1",true,null,"email=$EMAIL&pass=$PASSWORD");
preg_match('%Set-Cookie: ([^;]+);%',$a,$b);
$c = cURL("https://login.facebook.com/login.php?login_attempt=1",true,$b[1],"email=$EMAIL&pass=$PASSWORD");
preg_match_all('%Set-Cookie: ([^;]+);%',$c,$d);
for($i=0;$i<count($d[0]);$i++)
$cookie.=$d[1][$i].";";
echo cURL("http://graph.facebook.com/oauth/authorize?client_id=APP_IDredirect_uri=APP_REDIRECT_URL&display=touch&scope=publish_stream, user_checkins, publish_checkins, offline_access",null,$cookie,null);
?>
请帮我做。这是我的任务
提前致谢