AMFPHP + Facebook
我正在使用 AMFPHP 开发 Facebook 应用程序。我让 AMFPHP 和 Facebook SDK 正常工作,我的问题是,当我通过 AMFPHP 网关调用服务来访问将连接到 FB 并返回 UID 的服务时,我得到一个空值。我的猜测是我在将 AMFPHP 服务连接到 FB 平台时做错了什么。
这是 gateway.php
<?php
define("PRODUCTION_SERVER", false);
include "libraries/amfphp/globals.php";
include "libraries/amfphp/core/amf/app/Gateway.php";
$gateway = new Gateway();
$gateway->setClassPath("./services");
$gateway->setClassMappingsPath("./services/vo");
$gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1");
$gateway->setErrorHandling(E_ALL ^ E_NOTICE);
if(PRODUCTION_SERVER)
{
$gateway->disableDebug();
$gateway->disableStandalonePlayer();
}
$gateway->enableGzipCompression(25*1024);
$gateway->service();
?>
,这是测试服务:
<?php
require_once("../libraries/facebook.php");
class Test
{
public function uid()
{
$facebook = new Facebook(array(
'appId' => 'XXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
'cookie' => false,
));
$session = $facebook->getSession();
return $facebook->getUser();
}
}
有人知道我可能做错了什么吗?
PS:我在服务类中跳过了登录和权限验证,假设用户已经登录并拥有必要的权限。
I'm developing a Facebook APP with AMFPHP. I got the AMFPHP working, and the Facebook SDK, my problem is that when I call a service through AMFPHP gateway to access a service that will connect to FB and return the UID, for example, I get a null value. My guess is that I'm doing something wrong connect the AMFPHP service to the FB platform.
This is the gateway.php
<?php
define("PRODUCTION_SERVER", false);
include "libraries/amfphp/globals.php";
include "libraries/amfphp/core/amf/app/Gateway.php";
$gateway = new Gateway();
$gateway->setClassPath("./services");
$gateway->setClassMappingsPath("./services/vo");
$gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1");
$gateway->setErrorHandling(E_ALL ^ E_NOTICE);
if(PRODUCTION_SERVER)
{
$gateway->disableDebug();
$gateway->disableStandalonePlayer();
}
$gateway->enableGzipCompression(25*1024);
$gateway->service();
?>
and this is the test service:
<?php
require_once("../libraries/facebook.php");
class Test
{
public function uid()
{
$facebook = new Facebook(array(
'appId' => 'XXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
'cookie' => false,
));
$session = $facebook->getSession();
return $facebook->getUser();
}
}
Anyone knows what I might be doing wrong?
PS: I skipped the login and permission verification in the service class, assuming that the user is logged in and have the necessary permission.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您想检索调用 AMF 服务的用户的用户信息,但问题是,当您使用 appId 和 appSecret 实例化 Facebook SDK 类时,没有用户登录,您只有您的应用程序连接到 Facebook。如果您想在应用程序中维护 Facebook 用户会话,则必须在 Web 应用程序中实现 Facebook connect,这将使您能够检索 Facebook 会话,然后您可以使用该会话代表用户向 Facebook 发出请求。您可以在此处了解更多相关信息。
It seems that you would like to retrieve the user information of the user who calls the AMF service, but the problem is that when you instantiate the Facebook SDK class with your appId and appSecret, there is no user logged in, you just had your application connected to Facebook. If you want to maintain a Facebook user session in your application, you have to implement Facebook connect in your web app, which will enable you to retrieve a Facebook session, then you can use that session to make request to Facebook on behalf of the user. You can read more about it here.