1
我已經使用twitter oauth和facebook庫登錄到我的網站。它現在工作正常,現在它不工作:(。我有調試代碼,並知道Twitter訪問令牌和祕密不返回。對於臉譜登錄也沒得到用戶id.pls幫助如何使用codeigniter將twitter登錄和Facebook登錄整合到網站中?
我已經使用twitter oauth和facebook庫登錄到我的網站。它現在工作正常,現在它不工作:(。我有調試代碼,並知道Twitter訪問令牌和祕密不返回。對於臉譜登錄也沒得到用戶id.pls幫助如何使用codeigniter將twitter登錄和Facebook登錄整合到網站中?
第1步:下載Facebook庫https://github.com/facebook/facebook-php-sdk/tree/master/src
第2步:上傳它在\程序\庫
第3步:創建一個Facebook application.You WIL得到appId和secretcode.Paste在你的控制器的facebook()函數下面的代碼。設置appId和祕密。
$config = array(
'appId' => '234353465466',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'fileUpload' => true, // Indicates if the CURL based @ syntax for file uploads is enabled.
);
$this->load->library('Facebook',$config);
$user = $this->facebook->getUser();
if($user){
try {
$profile = $this->facebook->api('/me?fields=id,name,link,email');
}
catch (FacebookApiException $e) {
$user = null;
}
echo '<pre>';
print_r($profile);
第4步:將下面的代碼粘貼到視圖頁面中並更改appId和域名。
<div id="fb-root"></div>
<script type="text/javascript">// <![CDATA[
window.fbAsyncInit = function() {
FB.init({appId: '234463456', status: true, cookie: true,xfbml: true,oauth: true});};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol+'//connect.facebook.net/en_GB/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
function login()
{
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
document.location.href = "http://www.mydomain.com/facebook?accessToken="+response.authResponse.accessToken;
}
});
}
// ]]></script>
<fb:login-button scope="email" onlogin="login();" >Sign in with Facebook</fb:login-
感謝ü這麼多Jerin我會嘗試一下:) – Mhansi
感謝ü這麼多它的工作:) :)需要幫助Twitter的登錄 – Mhansi
嘗試在google..I有隻有Facebook的現成的代碼..一旦你拿到代碼,就把它放在這裏。嘗試 –