用于站点馈送的Facebook访问令牌

PiT*_*ber 2 javascript php jquery facebook facebook-graph-api

我正在尝试使用以下命令从我的网页加载Facebook Feed:

https://graph.facebook.com/177610425663218/feed

为此,我从Graph Explorer获得了一个访问令牌.问题是令牌一直在用完:

Error validating access token: Session has expired at unix time ...
Run Code Online (Sandbox Code Playgroud)

我知道我可以创建OAuth登录以获取新令牌,但我想在网页上显示Feed.我不想OAuth页面的所有访问者.如何获取网站订阅源的常量访问令牌?

PiT*_*ber 6

您可以轻松获得访问令牌.只需创建一个应用程序并使用app_id和登录app_secret:

$response = file_get_contents('https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=some_app_id&client_secret=the_appsecret');
$token = str_replace('access_token=', '', $response);
Run Code Online (Sandbox Code Playgroud)

适合我.