简体   繁体   English

将变量传递到 Facebook iFrame 应用程序 PHP

[英]Pass variables into Facebook iFrame app PHP

I thought this was possible, but it doesn't seem like I can do it.我认为这是可能的,但似乎我做不到。

What I'm looking at doing is passing a variable into a facebook iframe application.我正在做的是将变量传递facebook iframe 应用程序。 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…是的(到下面),如果其他人寻找这种用途,我找到了这些物品……

Create links...创建链接...

$link_params = array(
    'item1' => "blah",
    'item2'   => "blaaaaargh"
);
$encodedParams = urlencode(json_encode( $link_params )); 
//added to link as app_data

Get 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']

There is acutally something: the app_data in the signed_request .确实有一些东西: signed_request中的app_data The documentation says:文档说:

A JSON string containing the content of a query string parameter also called app_data.包含查询字符串参数内容的 JSON 字符串,也称为 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.仅当您的应用是加载在页面选项卡中的 iframe 时才可用。

This means, you simply call your app, add &app_data=... to the url.这意味着,您只需调用您的应用程序,将&app_data=...添加到 url。 Remember to encode the parameters to json first.记得先将参数编码为 json。

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

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