将变量传递到Facebook iFrame app PHP [英] Pass variables into Facebook iFrame app PHP
问题描述
我认为这是可能的,但似乎我无法做到。
I thought this was possible, but it doesn't seem like I can do it.
我正在做的是传递变量 进入 facebook iframe应用程序。不管怎么样,但我一直在尝试几种不同的方法。如果有人有任何想法。
What I'm looking at doing is passing a variable into a facebook iframe application. It doesn't matter how, but I've been trying a couple different methods. If anyone has any idea.
-----编辑---------
-----edit---------
是(到下面),如果有其他人寻找此用途我找到了这些物品...
Yes (to below), I found the items if anyone else looks for this use…
创建链接...
$link_params = array(
'item1' => "blah",
'item2' => "blaaaaargh"
);
$encodedParams = urlencode(json_encode( $link_params ));
//added to link as app_data
获取数据...
if (!empty($signed_request) && !empty($signed_request['app_data'])) {
$app_data = json_decode($signed_request['app_data'], true);
} //use in your app from here as $app_data['item1']
推荐答案
app_data / signed_request /> signed_request 。文档说:
There is acutally something: the app_data
in the signed_request. The documentation says:
包含查询字符串参数内容的JSON字符串也是
,称为app_data。通常在应用程序构建链接
以将某些数据传递给自身时指定。仅当您的应用是在页面标签中加载的iframe
时才可用。
A JSON string containing the content of a query string parameter also called app_data. Usually specified when the application built the link to pass some data to itself. Only available if your app is an iframe loaded in a Page tab.
这意味着,您只需拨打您的应用,将& app_data = ...
添加到网址。记得首先将参数编码为json。
This means, you simply call your app, add &app_data=...
to the url. Remember to encode the parameters to json first.
这篇关于将变量传递到Facebook iFrame app PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!