获取当前标签的 Facebook 页面标签 ID? [英] Get Facebook Page Tab ID of current Tab?

查看:23
本文介绍了获取当前标签的 Facebook 页面标签 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何获取用户正在访问的 Facebook 页面的当前标签的标签 ID.

I am trying to figure out how to get the tab ID of the current tab of a Facebook Page the user is visiting.

我制作了一个用于在 Facebook 主页上安装的应用程序,我需要为每个实例保存设置.我发现您可以为安装应用程序的页面获取一系列选项卡,但我不知道如何获取您所在的实际选项卡的选项卡 ID.

I have made an app for installation on Facebook Pages, that I need to save settings for, per instance. I have figured out that you can get an array of tabs for the page the app is installed on, but I can't figure out how to get the tab ID for the actual tab you're on.

重点是让管理员能够使用单个后端为他们添加了应用程序的每个选项卡保存设置.我不确定您是否可以在同一页面上拥有一个应用程序的多个实例,但如果不能,我们将在 iframe 中有 2-3 个具有相同后端的重复应用程序.因此,我需要能够将应用安装识别为唯一 - 我能找出的最好方法是使用应用的页面 ID 和标签 ID.

The point is for an admin to be able to save settings for each tab that they've added the app to, using a single backend. I'm not sure if you can have multiple instances of one app on the same page, but if not, we'd have 2-3 duplicate apps with the same backend in the iframe. Because of that, I need to be able to identify app installations as unique - the best way I can figure out is through using the page id and tab id, for the app.

我该怎么做?

更新:发现一个页面上每个应用只能有一个实例.

UPDATE: Found out that you can only have one instance per app on a page.

有了这个,我继续使用这个解决方案(使用/tabs/"来获取标签信息):

With that, I went with using this solution (with '/tabs/' to get the tab info):

try { 
  $tab = $facebook->api('/'.$fb_page_id.'/tabs/'.$fb_app_id);
  $fb_tab_link = $tab['data'][0]['link'];
} catch (FacebookApiException $e) {
  echo '<!-- '.htmlspecialchars(print_r($e, true)).' -->';
}

在上面的代码中,$fb_tab_link$fb_page_id$fb_app_id 的组合可以用作唯一标识符.我决定使用连接 $fb_page_id .'-' .$fb_app_id 作为实例 ID.

In the above code, $fb_tab_link or a combination of $fb_page_id and $fb_app_id can be used as unique identifier. I decided to use the concatenation $fb_page_id . '-' . $fb_app_id as the instance ID.

推荐答案

经过一番研究,我找到了通过 API 获取选项卡信息的调用.

After some research, I found the call to get the tab information via the API.

try { 
  $tab = $facebook->api('/'.$fb_page_id.'/tabs/'.$fb_app_id);
  $fb_tab_link = $tab['data'][0]['link'];
} catch (FacebookApiException $e) {
  echo '<!-- '.htmlspecialchars(print_r($e, true)).' -->';
}

显然,标签 ID 是页面 ID 和应用 ID 的组合,这意味着您不能将同一个应用安装到页面上的多个标签.

Apparently, the tab ID is the combination of Page ID and App ID, which means that you cannot install the same app to more than one tab on a page.

我希望这对需要为 Facebook 主页上的标签查找唯一 ID 的人有所帮助.

I hope this can be helpful to someone who needs to find the unique ID for a tab on a Facebook Page.

这篇关于获取当前标签的 Facebook 页面标签 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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