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

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

问题描述

我想知道如何获取用户正在访问的Facebook页面当前标签的标签ID。



我已经安装了一个应用程序在Facebook页面上,我需要为每个实例保存设置。我已经弄清楚,您可以获取一系列的应用程序安装的页面的选项卡,但我无法弄清楚如何获取您所在实际选项卡的标签ID。



要点是管理员可以使用单个后端将每个已添加应用的标签的设置保存。我不知道您是否可以在同一页面上拥有一个应用程序的多个实例,但如果不是,则我们将在iframe中拥有相同后端的2-3个重复的应用。因此,我需要能够识别应用程序安装是唯一的 - 我可以通过使用页面ID和标签ID来获取应用程序的最佳方法。



我该怎么做?



更新:发现,每个应用程序只能在一个页面上有一个实例。 >

我用这个解决方案(用'/ tabs /'获取标签信息):

  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。

解决方案

经过一番研究,我发现呼叫得到标签信息通过API。

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

显然,标签ID是页面ID和应用ID的组合,意味着您无法将相同的应用程序安装在页面上的多个选项卡上。



我希望这可以帮助需要查找标签的唯一ID的人在Facebook页面上。


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

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.

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.

How do I do that?

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

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)).' -->';
}

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.

解决方案

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)).' -->';
}

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.

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天全站免登陆