你将如何使用Facebook php sdk来执行`debug_token`调用? [英] How would you perform `debug_token` call using facebook php sdk?

查看:183
本文介绍了你将如何使用Facebook php sdk来执行`debug_token`调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档,端点看起来像

GET /debug_token?
     input_token={input-token}&
     access_token={access-token}

其中


input_token:要获取有关

的访问令牌access_token :您的应用访问令牌或来自应用开发人员的有效用户访问令牌

input_token: the access token you want to get information about
access_token: your app access token or a valid user access token from a developer of the app

假设我没有应用程序开发人员的有效用户访问令牌 - 只是因为我不想每2个月刷新一次,并始终牢记 - 我如何使用应用访问令牌执行?

Assuming I don't have a "valid user access token from a developer of the app" - just because I don't want to refresh it every 2 months and keep always it in mind - how would I perform it using "app access token"?

getApplicationAccessToken()方法受到保护,所以没有办法访问它而不将其覆盖到public。

The getApplicationAccessToken() method is protected, so there is no way to access it without overriding it to public.

我缺少的任何优雅的解决方案?

Any elegant solution that I'm missing?

PS:一个调用示例,会失败与你必须提供应用程序访问令牌或作为应用程序的所有者或开发人员的用户访问令牌由于缺少访问令牌而导致错误:

PS: a call example that would fail with "You must provide an app access token or a user access token that is an owner or developer of the app" error due to lack of access token:

$tokenDebug = $fb->api('debug_token', array(
    'input_token' => $token,
));

PPS:有趣的事情是,上面的错误不会出现在每个 $ token ,但对于某些人而言,我看不出令牌失败和成功的明显区别。

PPS: the "interesting" thing is that the error from above would appear not for every $token but for some, and I cannot see any obvious distinction between tokens that fail and that succeed.

PPPS: $ token 是一个用户访问令牌

PPPPS:为FB PHP SDK创建了一个功能请求 https://developers.facebook.com/bugs/637897982899835

PPPPS: Created a feature request for FB PHP SDK https://developers.facebook.com/bugs/637897982899835

PPPPPS:可能更好地创建一个拉请求,但是上午1:30,我太累了

PPPPPS: Probably it could be better to create a pull request instead, but it's 1:30am and I'm too tired for that

推荐答案

确定,所以如果需要一个应用程序访问令牌, app_id | app_secret (两个值连接在中间的管道符号)总是工作

OK, so if one needs an app access token, app_id|app_secret (both values concatenated with a pipe symbol in the middle) always works.

方法 getApplicationAccessToken 似乎在PHP SDK中受到保护,高达3.2.2 - 而 getAppId getAppSecret 已经在该版本中公开;所以这些可以替代硬编码和秘密的地方。

The method getApplicationAccessToken seems to have been protected in the PHP SDK up to 3.2.2 – whereas getAppId and getAppSecret are already public in that version; so those could be the alternative to hard-coding id and secret in place.

这篇关于你将如何使用Facebook php sdk来执行`debug_token`调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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