在本地主机上运行 Facebook 应用程序 [英] Running Facebook application on localhost

查看:67
本文介绍了在本地主机上运行 Facebook 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算从我的本地主机连接到 Facebook 聊天.我需要从 Facebook 获取会话密钥.当我将站点 URL 指定为 localhost:8080ip-address:8080 时,它不起作用.

I am planning to connect to Facebook chat from my localhost. I will need to get the session key from Facebook. When I give the site URL as localhost:8080 or ip-address:8080 it does not work.

我读过关于使用 2 个不同的 API 密钥设置两个应用程序,一个在 dev m/c 上运行,另一个在本地主机上运行,​​但我不太明白.

I read about setting up two apps with 2 different API keys one runs on dev m/c and other on localhost but I did not quite get it.

谁能解释一下如何在本地主机上运行 Facebook 应用程序?

Can anyone explain how to run a Facebook app on localhost?

推荐答案

我写了一个 教程 不久前关于这个.

I wrote a tutorial about this a while ago.

最重要的一点是站点 URL":

The most important point is the "Site URL":

网站网址: http://localhost/app_name/

文件夹结构类似于:

app_name
¦   index.php
¦
+---canvas
¦   ¦   index.php
¦   ¦
¦   +---css
¦           main.css
¦           reset.css
¦
+---src
        facebook.php
        fb_ca_chain_bundle.crt


Kavya:即使没有 IP 或端口,FB 服务器如何识别我的本地主机?


Kavya: how does the FB server recognize my localhost even without an IP or port??

我不认为这与 Facebook 有任何关系,我猜测因为 iframe src 参数是从客户端加载的,它会处理您的本地 URL就像你直接把它放在浏览器上一样.

I don't think this has anything to do with Facebook, I guess since the iframe src parameter is loaded from client-side it'll treat your local URL as if you put it directly on your browser.

例如,在您的在线服务器上有一个包含内容的文件(例如 online.php):

For example have a file on your online server with content (e.g. online.php):

<iframe src="http://localhost/test.php" width="100%" height="100%">
    <p>Not supported!</p>
</iframe>

在你的本地主机根目录中,有文件 test.php:

And on your localhost root directory, have the file test.php:

<?php echo "Hello from Localhost!"; ?>

现在访问 http://your_domain.com/online.php 你会看到你的 localhost 文件的内容!

Now visit http://your_domain.com/online.php you will see your localhost file's content!

这就是为什么实时订阅和取消授权回调(仅提一下)不会与本地主机 URL 一起使用!因为 Facebook 会 ping(发送 http 请求)到这些 URL,但显然 Facebook 服务器不会将这些 URL 转换为您的 URL!

This is why realtime subscriptions and deauthorize callbacks (just to mention) won't work with localhost URLs! because Facebook will ping (send http requests) to these URLs but obviously Facebook server won't translate those URLs to yours!

这篇关于在本地主机上运行 Facebook 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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