设置Facebook应用程序?

时间:2011-05-31 08:34:53

标签: php facebook api sdk

我有以下设置我的申请

sandbox is enable and fbml is disable

但应用程序仅对我的帐户可见。如果我使用其他帐户登录并访问应用程序网址,则会显示

The page you requested was not found.

如果我禁用沙箱然后说错误

Switch to regular connection (http)?

然后如何从我的网页cpanel设置https。

Even if disable sandbox then application become unable to access user information

如何解决所有问题...

So is there any tutorial to setup latest Facebook application with php SDK 3.0 
WORKING ONE, THERE ARE ALOT IN GOOGLE BUT WERE OLD AND NOT WOKING NOW

3 个答案:

答案 0 :(得分:0)

这样做的好方法是使用Facebook PHP SDK(see on github)。所以你会有类似的东西:

require "facebook.php";
$facebook = new Facebook(array(
    'appId'  => YOUR_APP_ID,
    'secret' => YOUR_APP_SECRET,
));

$user = $facebook->getUser();

if ($user) {
  try {
    $facebook->api('/me');
  } catch (FacebookApiException $e) {
    $user = null;
  }
}

然后,您需要显示登录或注销链接:

<?php if ($user): ?>
    <a href="<?php echo $facebook->getLogoutUrl() ?>">Logout of Facebook</a>
<?php else: ?>
    <a href="<?php echo $facebook->getLoginUrl() ?>">Login with Facebook</a>
<?php endif ?>

当用户登录并且您拥有有效的访问令牌时,您可以进行API调用以从Facebook获取数据:

$user_profile = $facebook->api('/me');

您可能需要查看记录良好的example page of the Facebook PHP SDK

希望有所帮助。

答案 1 :(得分:0)

您正在寻找:

$facebook->getLoginUrl();

$facebook->getLogoutUrl();
在getLoginUrl中,你必须指定你想要的权限。 e.g

  $url = $facebook->getLoginUrl(array(
   'req_perms' => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'
  ));

您可以在“a href”链接中使用网址或直接简单地重定向。 (如果你在facebook iframe中,你必须使用top.location!)

有关完整示例,请参阅https://github.com/facebook/php-sdk/blob/master/examples/example.php

答案 2 :(得分:0)

您的应用程序在哪里托管?您必须具有安全画布URL才能禁用沙盒模式。 I.E. https链接(SSL)。