Facebook 应用程序对 cron 作业的授权
我有一个 Facebook 应用程序,可以发送链接到粉丝页面墙。当我从浏览器调用 .php 文件时,一切正常,但当我从 cronjob 调用同一页面时,由于授权问题,它无法运行 facebook 应用程序。我不想在 php 文件中输入我的用户名/密码。是否有一个设置来授权 cronjob 并发布到页面墙?
I have an facebook application which sends links to fan page walls. Everything is working when i call the .php file from my browser but when i call the same page from cronjob it can't run the facebook application because of the authorization problem. I don't want to enter my username/password to the php file. Is there a setting to authorize the cronjob and post to page walls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不认为你可以使用 cronjobs 授权任何 facebook 应用程序,你必须手动授权,然后使用你的墙贴链接创建一个 cron 作业!
I don't think you can authorize any facebook application using cronjobs, you have to authorize manually and then create a cron job with your wall posting link!
cron 对 Facebook 和 Facebook 凭证一无所知,这是一件好事。如果您希望脚本自动使用 Facebook 执行操作,则需要将您的凭据嵌入到脚本中,或者授予脚本访问存储凭据的某些位置的权限。
cron knows absolutely NOTHING about Facebook and Facebook credentials, and this is a good thing. If you want a script to do things automatically with Facebook, you'll need to embed your credentials in the script, or give the script access to some place the credentials are stored.
如果这是每个用户的事情,您需要让用户对您的应用程序进行身份验证,并请求离线访问扩展权限(除了您可能需要的其他权限之外),并将生成的访问令牌存储在某种数据库中。然后,您可以随时使用该访问令牌以该用户身份进行发布(除非该令牌因更改密码或撤销访问而被停用)。
如果您只需要为自己的帐户执行此操作,您将执行获取离线访问令牌的相同过程,但您可以将此访问令牌嵌入到应用程序的代码中。
If this is a per user thing, you would need to have a user authenticate with your application, and request offline_access extended permission (in addition to other permissions you might need), and store the resulting access token in some kind of database. You could then publish as that user using that access token at any time (unless the token gets deactivated by them changing their password or revoking access).
If you just need to do this for your own account, you would do the same process of getting an offline_access token but you could just embed this access token into the code of your application.