dongyuluan7494 2012-02-23 15:18
浏览 22

如何在查询字符串中将一些值传递给我的Facebook画布应用程序?

I have developed a facebook canvas app which posts to users newsfeeds and I want to be able to allow users to click on the link in the newsfeed and be taken to my app along with some data that will be presented in the app (for example by passing it in the querystring).

When I create the link that will be posted on user's newsfeed I set the link field to -

http://apps.facebook.com/myappname/?datatopass=mydata

This works, when a user clicks this link the browser directs them to that link. However I cannot access the $_GET['datatopass'] variable (using PHP) and it appears to be blank. I have tried using javascript to output the window.location variable and I don't see my passed querystring, even though I see the url as it is above in my browser address bar. What I do see is the site url that i set up in the facebook developer app and the state and code params that facebook uses. It has stripped my datatopass param that I wanted to be able to read when my app launched.

So ... how can I pass along the data that I want to send? I know there is an app_data field if you are using signed_request but as I understand it this is only good for apps that sit in a Tab of a Page. I am using the iFrame canvas app method.

When I look at my apache server's access logs I can see that there is a POST entry for my site url address with my appended querystring -

my.domain.com 123.456.7.890 - - [23/Feb/2012:14:21:19 +0000] "POST /facebookapp/?datatopass=mydata HTTP/1.1" 200 300 "http://apps.facebook.com/myappname/?datatopass=mydata" "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0"

Followed by a GET entry -

my.domain.com 123.456.7.890 - - [23/Feb/2012:14:21:20 +0000] "GET /facebookapp/directory/?state=99226fiawhoidhaoia09809a085d94832&code=ahfakshdlkfhalksj.... HTTP/1.1" 200 27094 "http://my.domain.com/facebookapp/?play=asd" "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0"

My apologies I dont really understand what the above is doing but hoped it would be useful extra information in helping to answer this.

  • 写回答

5条回答 默认 最新

  • dsa111111 2012-02-23 15:22
    关注

    You may need a / after the app name in the URL i.e..

    http://apps.facebook.com/myappname/?datatopass=mydata

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)