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

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

问题描述

我计划从本地主机连接到Facebook聊天。我将需要从Facebook获取会话密钥。当我将站点URL设置为 localhost:8080 ip-address:8080 它不起作用。



我阅读了关于使用2个不同的API密钥设置两个应用程序,一个在dev m / c上运行,另一个运行在localhost上,但我没有得到它。

任何人都可以解释如何在localhost上运行Facebook应用程序?

解决方案

关于这一段时间的教程



最重要的一点是网站URL:


站点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 FB服务器如何识别我的本地主机即使没有IP或端口?



我不认为这与Facebook有任何关系,我猜,因为iframe src 参数是从客户端加载的,它会将您的本地URL视为直接放在浏览器上。



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

 < iframe src =http://localhost/test.phpwidth =100%height =100%> 
< p>不支持!< / p>
< / iframe>

在您的localhost根目录下,有文件 test.php

 <?php echoHello from Localhost! ?> 

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



这就是为什么实时订阅和取消授权回调(仅提及)不能使用localhost网址!因为Facebook将ping(发送http请求)到这些URL,但显然Facebook服务器不会将这些URL转换为您的!


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.

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.

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

解决方案

I wrote a tutorial about this a while ago.

The most important point is the "Site URL":

Site URL: http://localhost/app_name/

Where the folder structure is something like:

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

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

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.

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>

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

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

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

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!

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

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