Facebook require_login不工作 [英] Facebook require_login not working

查看:82
本文介绍了Facebook require_login不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的小Facebook应用程序有一些麻烦,我不断得到这个friggin错误,致命的错误:调用未定义的方法Facebook :: require_login(),现在有趣的是,我完全相同的代码正在为其他人,但不适合我,这里是代码。

 <?php 
require_once( php-sdk / src / facebook.php);
$ api_key =my_api_key;
$ secret =my_secret_key;

$ facebook = new Facebook($ api_key,$ secret);
$ user_id = $ facebook-> require_login();

echoHello World;
echo当前登录为< fb:name uid = \$ user_id \/>;
?>

你可以看到它是一个简单的hello USER应用程序,但由于某种原因,REFUSES可以工作我,所以如果任何人可以帮助,这将是伟大的,thanx提前!

解决方案

你使用最新版本的PHP sdk



Facebook :: require_login()是旧SDK中的一种方法。



新的SDK API)不向后兼容。



需要登录的概念甚至不再存在 - 您只需获取用户的ID即可。

  $ user_id = $ facebook-> getUser(); 


I am having some trouble with my little facebook application, I keep getting this friggin error, "Fatal error: Call to undefined method Facebook::require_login()", now the funny bit is that my exact same code is working for other people, but not for me, here is the code.

<?php
require_once( "facebook-php-sdk/src/facebook.php" );
$api_key = "my_api_key";
$secret = "my_secret_key";

$facebook = new Facebook( $api_key, $secret );
$user_id = $facebook->require_login();

echo "Hello World";
echo "Current logged in as <fb:name uid=\"$user_id\" />";
?>

As you can see it is a simple hello USER application, but for some reason this REFUSES to work for me, so if anyone can help out that would be great, thanx in advance!

解决方案

Are you using the newest version of the PHP sdk?

Facebook::require_login() is a method from the old SDK.

The new SDK (published in conjunction with the Graph API) is not backwards compatible.

The notion of requiring a login doesn't even exist anymore - you just obtain the user's ID as such.

$user_id = $facebook->getUser();

这篇关于Facebook require_login不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆