使用oauth登录Facebook [英] login with facebook using oauth
问题描述
<?php
requirefacebook.php;
$ facebook = new Facebook(array(
'appId'=>'3288 @@@@@@@@@',
'secret'=> 'ca2 @@@@@@@@@@@@@@@@',
));
$ user = $ facebook-> getUser();
我已经在图形API中制作了应用程序,我对图形API的知识很少。我想要一个Facebook登录页面,用户点击它,我的应用程序将为用户生成oauth。之后,我需要用户名,EMAIL,BIRTHDAY,NAME在自己填写的表单
我正在从3晚搜索这段代码,但是我没有找到解!如果您有建议,请写信给我!请不妨谢谢,祝你好运!)
您可以使用POST请求来模拟登录。我不知道Facebook的输入,所以你需要仔细查看它的HTML,但是这里是一个简单的PHP cURL请求的代码。
//获取cURL资源
$ curl = curl_init();
//设置一些选项 - 我们也在这里传递一个用户名
curl_setopt_array($ curl,array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL =>'https: //www.facebook.com/login.php',
CURLOPT_USERAGENT =>'Facebook登录',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS =>数组(
'username'=>'username',
'password'=>'myfbpass'
)
));
//发送请求&保存对$ resp
$ resp = curl_exec($ curl)的响应;
//关闭请求以清除一些资源
curl_close($ curl);
http://z8games.com/ 登录p>
祝你好运
代码信用:
http://codular.com/curl-with-php
编辑:
如果你很懒,可以继续尝试这个页面 - http://www.daniweb.com/web-development/php/code/290893/facebook-login-with-curl
<?php
require "facebook.php";
$facebook = new Facebook(array(
'appId' => '3288@@@@@@@@@@',
'secret' => 'ca2@@@@@@@@@@@@@@@@@@',
));
$user = $facebook->getUser();
I have made the app in the graph api and I have very little knowledge of graph api . I want to make a facebook login page in which user clicked on it and my app will generate the oauth for the user . after that i need the USERNAME, EMAIL,BIRTHDAY,NAME in the fre filled forms
I'm searching for this code from 3 night, but i didn't find the solution! If you have a suggestion, please write to me it! Please, anyway thanks and good day :)
You could use POST request to simulate login. I don't know Facebook's inputs, so you need to look closely into it's HTML, but here is a code for a simple PHP cURL request.
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://www.facebook.com/login.php',
CURLOPT_USERAGENT => 'Facebook Login',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
'username' => 'username',
'password' => 'myfbpass'
)
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
Of course, Facebook has automatic login detection by using those hidden fields for getting the sessions, but using DOM Document, you can easily get those values and emulate it, at least thats how I was able to simulate login for http://z8games.com/
Good luck
Code Credit: http://codular.com/curl-with-php
Edit:
If you are lazy, you can go ahead and try this page - http://www.daniweb.com/web-development/php/code/290893/facebook-login-with-curl
这篇关于使用oauth登录Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!