facebook apps:安排任务 [英] facebook apps: scheduling a task

查看:319
本文介绍了facebook apps:安排任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Facebook应用程序中安排任务,我将要创建?我想每周都会运行一些操作。



编辑
例如我想安排在某人的墙上发布一些东西在一个星期的某个时间可以吗?



EDIT2
我还可以从我的应用程序向用户发送私人消息,而不是在

解决方案

你能解释一点吗?



Facebook应用程序无法运行预定任务,但Facebook应用程序主要是连接到Facebook或iframe的网站集成到Facebook中。



所以你必须直接在你的服务器上运行你的计划的任务,例如 CRON工作



一个简单的例子:



让我们说您的Facebook应用程序位于: http://yourserver.com/facebookapp1/
您可以安排您的服务器上将会调用该页面的任务 http://yourserver.com/facebookapp1/scheduledtaks/



所以基本上每周或每天都会打电话给这个网页,这个页面会做你所需要做的任务,以便维护...



你有一个Web服务器?你能添加cron工作吗?你的服务器技术是什么?
如果你给我们更多的信息,我们可以给你一个更具体的答案...



要回答你的修改: p>

有可能,您需要创建一个脚本,您可以每天调用这个脚本。我们来打电话给check_and_send。现在您的脚本将需要检查是否要发送某些内容(这取决于您的逻辑),例如查看数据库以查看是否需要在今天发布某些内容。当它想要发布一些东西时,可以使用 Facebook图表API >。您将需要向用户请求publish_stream权限。



此外,您还需要一个初步步骤,您可以在此询问用户对Facebook进行身份验证,并询问他授予您的应用程序publish_stream权限,但还要offline_access权限,因此您可以随时发布到用户墙(而不仅仅是连接时)...请参阅 Facebook权限



之后,您将不得不保存access_token(对于每个用户)在你的数据库或某个地方,你会使用它,当你需要发布在该特定用户的墙上...



所以简而言之: p>

1)(一次)验证用户,请求权限,保存为Facebook UID和access_token



2)定期)在您的数据库中检查是否需要发布,如果是使用Facebook图表API发布,并保存access_toke n。


Is there any way to schedule a task in a Facebook app, that I am going to create? I would like it to run some operation every week.

EDIT For example I would like to schedule posting something on someone's wall at certain time of a week. Is it possible?

EDIT2 And can I also send a private message to the user from my app instead of posting on a wall?

解决方案

Could you explain a little bit more ?

Facebook applications have NOT the ability to run scheduled tasks BUT facebook applications are mainly websites connected to facebook or iframes integrated into facebook.

So you'll have to run your scheduled tasks on your server directly using something like CRON jobs.

A quick example :

Let say your facebook application is located at : http://yourserver.com/facebookapp1/ You could schedule a task on your server that will call the page http://yourserver.com/facebookapp1/scheduledtaks/

So basically it will call this page every week or day and this page will do the job of doing whatever you need to for your maintenance ...

Do you have a web server ? Can you add cron jobs ? What is your server technology ? If you give us more information we could give you a more specific answer ...

To answer your edit :

It is possible, you need to create a script that you will call everyday for example. Let's call it check_and_send. Now your script would need to check if something is to be send (It depends on your logic) like check a DB to see if something need to be posted today or not. When it want to publish something it can do it using the facebook graph api. You will need to ask for the 'publish_stream' permission to the user.

Also you will need a preliminary step where you ask the user to authenticate to facebook and you ask him to grant your application the 'publish_stream' permission but ALSO the 'offline_access' permission, so you can publish to the user wall at any time (and not only when he is connected) ... see facebook permissions

After that you will have to save the access_token (for each user) in your DB or somewhere and you will use it when you need to post on the wall of that particular user ...

So in short :

1) (once) authenticate the user,ask for permissions, save it's facebook UID and access_token

2) (periodically) check in your DB if something need to be posted, if yes post it using the facebook graph api and the saved access_token.

这篇关于facebook apps:安排任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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