替换“通过 Graph API Explorer"按我的应用程序名称标记 [英] Replace "via Graph API Explorer" label by my application name

查看:22
本文介绍了替换“通过 Graph API Explorer"按我的应用程序名称标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Facebook 应用程序开发的新手.我整天都在玩如何在页面的墙上发布消息?".我终于成功了,但每条消息都是通过 Graph API Explorer".我试图找到如何将其更改为我的应用程序名称但没有成功.我试图看看我是否可以在 api 命令中强制应用程序的值,但它没有考虑到它.也许我错过了什么 :( 如果有人可以提供帮助,那就太好了!

I am quite new in Facebook application development. I was playing the all day with "how to post a message on the wall of a page?". I finally succeeded but each message got "via Graph API Explorer". I tried to find how to change it to my application name without success. I tried to see if I could force the value of application in the api command but it did not take it into account. Maybe I miss something :( If someone can help, that would be great!

我还是很困惑.让我试着解释一下我想要做什么:我想在一个页面上(作为页面)自动发布一些在网站上定义的事件(在某种议程中).我想,我想念的是 Facebook 方面的一切是如何协同工作的:1.登录过程:由于应用程序将在cron中运行,因此不应显示登录对话框.2.访问令牌:应用程序还是第一页?3.权限:根据我的理解,我需要manage_pages(和publish_stream)但不清楚应该如何设置.

I am still quite confused. Let me try to explain what I want to do: I would like to automatically publish on a page (as the page) some event that are defined on a website (in a kind of agenda). What I miss, I think, is how everything is working together on Facebook side: 1. the login process: as the application will run in a cron, this should not display a login dialog box. 2. the access token: application or page one? 3. the permissions: from my understanding, I need manage_pages (and publish_stream) but not clear how this should be set.

感谢任何澄清,也许是一个明显的例子:o)

Thx for any clarification and maybe a clear example :o)

推荐答案

好的,我想我终于找到了解决方案.我需要一个页面访问代码而不是应用程序访问代码.令牌必须在应用程序外部生成,作为长期存在的令牌.

OK I think I have finally found the way to do it. I needed a page access code and not an application access code. The token must be generated outside the application as a long live one.

  • 使用以下代码获取代码:

https://www.facebook.com/dialog/oauth?client_id={app_id}&redirect_uri={my_url}&scope=manage_pages,publish_stream

app_id 是您的应用程序 IDmy_url 是您的应用程序 URLscope 是您要授予的权限

app_id is your application ID my_url is your application URL scope is the permission you want to be granted

在重定向的 URL 中,您将有一个代码参数.复制它.

In the redirected URL, you will have a code parameter. Copy it.

  • 使用以下方法生成用户访问代码:

https://graph.facebook.com/oauth/access_token?client_id={app_id}&redirect_uri={my_url}&client_secret={app_secret}&code={code}

app_secret 是您的应用程序密钥代码是步骤 1 中的代码

app_secret is your application secret key code is the code from step 1

您将获得用户访问令牌作为输出.这是一个短命的.

You will get as output the user access token. This one is a short live one.

  • 使用以下方法将短期用户访问令牌转换为长期用户访问令牌:

https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id={app_id}&client_secret={app_secret}&fb_exchange_token={short live access token}

将短期访问令牌"替换为您在第 2 步中获得的令牌您将获得无限用户访问令牌作为输出.

Replace the "short live access token" by the one you got on step 2 You will get as output the infinite user access token.

  • 获取页面访问令牌(这将是无限访问令牌,因为用户访问令牌现在也是一个无限访问令牌):

https://graph.facebook.com/me/accounts?access_token={无限用户访问令牌}

将无限用户访问令牌"替换为您在第 3 步中获得的值.

Replace the "infinite user access token" with the value you got on step 3.

此命令将列出您管理的所有页面.输出包含您在access_token"字段中需要的页面访问令牌.因此,您可以在应用程序的任何 API 命令中使用此令牌.

This command will list all the pages you administer. The output contains the page access token you need in field "access_token". You can so use this token in any API command in your application.

最好的方法是通过服务器端程序(对我来说是 PHP)来完成所有这些步骤,因为应用程序密钥应该保持秘密".

The best of the best is to do all those steps via a server side program (PHP for me) as the application secret key should remain "secret".

这篇关于替换“通过 Graph API Explorer"按我的应用程序名称标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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