使用Heroku URL作为Canvas URL的凭据无效

时间:2023-01-12 18:28:31

I am using Heroku to make a php application on Facebook. I want to have the Heroku URL be the Canvas URL in my application. However, when I put the URL in the Basic page and then try to open my application by going to http://apps.facebook.com/status_related_test, the canvas displays "Invalid credentials" and redirects to the URL of the application, https://young-warrior-3712.herokuapp.com.

我正在使用Heroku在Facebook上制作一个php应用程序。我想让Heroku URL成为我的应用程序中的Canvas URL。但是,当我将URL放在Basic页面然后尝试通过http://apps.facebook.com/status_related_test打开我的应用程序时,画布显示“Invalid credentials”并重定向到应用程序的URL,https ://young-warrior-3712.herokuapp.com。

Any ideas what I might be doing wrong or how to fix this?

任何想法我可能做错了或如何解决这个问题?

ETA:
When I go directly to the application link (https://young-warrior-3712.herokuapp.com), I can sign in successfully. It is only when I try to go to the Facebook App page that it doesn't work.

ETA:当我直接进入应用程序链接(https://young-warrior-3712.herokuapp.com)时,我可以成功登录。只有当我尝试去Facebook App页面时,它才会起作用。

4 个解决方案

#1


4  

norabora, I got the solution for this in other post, after suffering long hours I finally made it! this is the link to the post I answered to: Answer to redirection in FB app canvas

norabora,我在其他职位上得到了解决方案,经过长时间的努力,我终于成功了!这是我回答的帖子的链接:回答FB应用程序画布中的重定向

Hope you'll find it useful... Good Luck!

希望你会发现它很有用......祝你好运!

#2


0  

Tried it myself, the index.php can't fetch $token on line 35 on page load.

我自己试过,index.php在页面加载时无法在第35行获取$ token。

$token = FBUtils::login(AppInfo::getHome());
if ($token) {
...
} else {
  // Stop running if we did not get a valid response from logging in
  exit("Invalid credentials");
}

Use the procedure from http://developers.facebook.com/docs/authentication/ to ascertain why FBUtils::login fails.

使用http://developers.facebook.com/docs/authentication/中的过程确定FBUtils :: login失败的原因。

Alternatively, you may want to use Facebook PHP SDK (http://developers.facebook.com/docs/reference/php/) which already has functions like "Facebook::getLoginUrl" and bypass this error.

或者,您可能希望使用已经具有“Facebook :: getLoginUrl”等功能的Facebook PHP SDK(http://developers.facebook.com/docs/reference/php/)并绕过此错误。

#3


0  

Go to the getHome() function in AppInfo.php and find the following line:

转到AppInfo.php中的getHome()函数,找到以下行:

return ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?: "http") . "://" . $_SERVER['HTTP_HOST'] . "/"; 

You have to change $_SERVER['HTTP_HOST'] to your canvas page URL:

您必须将$ _SERVER ['HTTP_HOST']更改为画布页面网址:

return ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?: "http") . "://" . "apps.facebook.com/yourappname"  . "/"; 

where yourappname should be your app namespace.

yourappname应该是您的app命名空间。

Note that if you apply these changes you won't be able to use the heroku page of your application because it will redirect to the canvas page.

请注意,如果您应用这些更改,您将无法使用应用程序的heroku页面,因为它将重定向到画布页面。

#4


0  

I was experiencing a similar problem trying to include my app in a pages tab on Facebook. The answer to the problem is to edit FBUtils.php.

我在尝试将我的应用程序包含在Facebook的页面选项卡中时遇到了类似的问题。该问题的答案是编辑FBUtils.php。

Find:

      echo("<script> window.location.href='" . $authorize_url . "'</script>");

Replace with:

echo("<script> window.location.href='" . $authorize_url . "'</script>");

This line can be found at line 94 of FBUtils.php

该行可以在FBUtils.php的第94行找到

#1


4  

norabora, I got the solution for this in other post, after suffering long hours I finally made it! this is the link to the post I answered to: Answer to redirection in FB app canvas

norabora,我在其他职位上得到了解决方案,经过长时间的努力,我终于成功了!这是我回答的帖子的链接:回答FB应用程序画布中的重定向

Hope you'll find it useful... Good Luck!

希望你会发现它很有用......祝你好运!

#2


0  

Tried it myself, the index.php can't fetch $token on line 35 on page load.

我自己试过,index.php在页面加载时无法在第35行获取$ token。

$token = FBUtils::login(AppInfo::getHome());
if ($token) {
...
} else {
  // Stop running if we did not get a valid response from logging in
  exit("Invalid credentials");
}

Use the procedure from http://developers.facebook.com/docs/authentication/ to ascertain why FBUtils::login fails.

使用http://developers.facebook.com/docs/authentication/中的过程确定FBUtils :: login失败的原因。

Alternatively, you may want to use Facebook PHP SDK (http://developers.facebook.com/docs/reference/php/) which already has functions like "Facebook::getLoginUrl" and bypass this error.

或者,您可能希望使用已经具有“Facebook :: getLoginUrl”等功能的Facebook PHP SDK(http://developers.facebook.com/docs/reference/php/)并绕过此错误。

#3


0  

Go to the getHome() function in AppInfo.php and find the following line:

转到AppInfo.php中的getHome()函数,找到以下行:

return ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?: "http") . "://" . $_SERVER['HTTP_HOST'] . "/"; 

You have to change $_SERVER['HTTP_HOST'] to your canvas page URL:

您必须将$ _SERVER ['HTTP_HOST']更改为画布页面网址:

return ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?: "http") . "://" . "apps.facebook.com/yourappname"  . "/"; 

where yourappname should be your app namespace.

yourappname应该是您的app命名空间。

Note that if you apply these changes you won't be able to use the heroku page of your application because it will redirect to the canvas page.

请注意,如果您应用这些更改,您将无法使用应用程序的heroku页面,因为它将重定向到画布页面。

#4


0  

I was experiencing a similar problem trying to include my app in a pages tab on Facebook. The answer to the problem is to edit FBUtils.php.

我在尝试将我的应用程序包含在Facebook的页面选项卡中时遇到了类似的问题。该问题的答案是编辑FBUtils.php。

Find:

      echo("<script> window.location.href='" . $authorize_url . "'</script>");

Replace with:

echo("<script> window.location.href='" . $authorize_url . "'</script>");

This line can be found at line 94 of FBUtils.php

该行可以在FBUtils.php的第94行找到