简体   繁体   English

使用Heroku URL作为画布URL的无效凭据

[英]Invalid Credentials using Heroku URL as Canvas URL

I am using Heroku to make a php application on Facebook. 我正在使用Heroku在Facebook上制作php应用程序。 I want to have the Heroku URL be the Canvas URL in my application. 我想让Heroku URL作为我的应用程序中的Canvas URL。 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 . 但是,当我将URL放在“基本”页面中,然后尝试通过转到http://apps.facebook.com/status_related_test打开我的应用程序时,画布显示“无效的凭据”并重​​定向到应用程序的URL https ://young-warrior-3712.herokuapp.com

Any ideas what I might be doing wrong or how to fix this? 有什么想法我可能做错了或如何解决?

ETA: ETA:
When I go directly to the application link (https://young-warrior-3712.herokuapp.com), I can sign in successfully. 当我直接转到应用程序链接(https://young-warrior-3712.herokuapp.com)时,我可以成功登录。 It is only when I try to go to the Facebook App page that it doesn't work. 只有当我尝试转到Facebook App页面时,它才无效。

norabora, I got the solution for this in other post, after suffering long hours I finally made it! norabora,在长时间的苦苦挣扎之后,我终于在其他职位上找到了解决方案! this is the link to the post I answered to: Answer to redirection in FB app canvas 这是我回答的帖子的链接: FB app canvas中的重定向答案

Hope you'll find it useful... Good Luck! 希望您会发现它有用...祝您好运!

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 PHP SDK(http://developers.facebook.com/docs/reference/php/),该SDK已经具有“ Facebook :: getLoginUrl”之类的功能,并绕过此错误。

Go to the getHome() function in AppInfo.php and find the following line: 转到getHome()中的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']更改$_SERVER['HTTP_HOST']画布页面URL:

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

where yourappname should be your app namespace. yourappname应该是您的应用程序名称空间。

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页面,因为它将重定向到画布页面。

I was experiencing a similar problem trying to include my app in a pages tab on Facebook. 尝试将我的应用程序包含在Facebook的页面选项卡中时,我遇到了类似的问题。 The answer to the problem is to edit FBUtils.php. 该问题的答案是编辑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行找到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM