简体   繁体   English

使用oauth登录facebook

[英]login with facebook using oauth

<?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 . 我已经在图形api中创建了应用程序,并且我对图形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 . 我想建立一个Facebook登录页面,用户点击它,我的应用程序将为用户生成oauth。 after that i need the USERNAME, EMAIL,BIRTHDAY,NAME in the fre filled forms 之后,我需要填写自由表格中的USERNAME,EMAIL,BIRTHDAY,NAME

I'm searching for this code from 3 night, but i didn't find the solution! 我正在寻找3晚的代码,但我没有找到解决方案! If you have a suggestion, please write to me it! 如果您有任何建议,请写信给我! Please, anyway thanks and good day :) 拜托,无论如何,谢谢你,美好的一天:)

You could use POST request to simulate login. 您可以使用POST请求来模拟登录。 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. 我不知道Facebook的输入,所以你需要仔细查看它的HTML,但这里是一个简单的PHP cURL请求的代码。

// 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);

Facebook的

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/ 当然,Facebook通过使用这些隐藏字段来获取会话进行自动登录检测,但是使用DOM Document,您可以轻松获取这些值并模拟它,至少我能够模拟http:// z8games的登录。 COM /

Good luck 祝好运

Code Credit: http://codular.com/curl-with-php 代码信用: 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 如果你很懒,你可以继续尝试这个页面 - http://www.daniweb.com/web-development/php/code/290893/facebook-login-with-curl

Temboo makes it simple to implement Facebook OAuth by breaking the process down into two steps: 通过将流程分为两个步骤, Temboo可以轻松实现Facebook OAuth:

  • ÌnitializeOAuth returns the Facebook authorization URL that you need to show your users so that they can grant your app access to their Facebook accounts. ÌnitializeOAuth返回您向用户显示所需的Facebook授权URL,以便他们可以授予您的应用访问其Facebook帐户的权限。
  • FinalizeOAuth returns the access token you need to programmatically read/write a user's Facebook data. FinalizeOAuth返回您以编程方式读取/写入用户的Facebook数据所需的访问令牌。

What's more, you can test these calls from your browser and generate the source code you need in the language of your choice. 更重要的是,您可以从浏览器测试这些调用,并以您选择的语言生成所需的源代码。

Here's a short video that shows you how to do this with Temboo, and you can check out an example and source code here . 这是一个简短的视频 ,向您展示如何使用Temboo执行此操作,您可以在此处查看示例和源代码。

(Full disclosure: I work at Temboo, so let me know if you have any questions!) (完全披露:我在Temboo工作,如果您有任何疑问,请告诉我!)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM