通过 Coldfusion Page 将 facebook 和 twitter 状态更新拉入 SQL 数据库

2022-01-09 00:00:00 twitter facebook sql-server coldfusion

我想设置一个 Coldfusion 页面,该页面将从我自己的 facebook 帐户和 twitter 帐户中提取状态更新,并将它们连同它们的时间戳一起放入 SQL 数据库中.每当我运行此页面时,它应该只在数据库中已有的最新时间戳之后获取信息.

I'd like to set up a coldfusion page that will pull the status updates from my own facebook account and twitter accounts and put them in a SQL database along with their timestamps. Whenever I run this page it should only grab information after the most recent time stamp it already has within the database.

我希望这不会太糟糕,因为我感兴趣的只是状态更新及其时间戳.最终,我想提取图像等其他内容,但对于第一次测试,只需状态更新即可.有没有人有可以帮助我完成这项工作的示例代码和/或指针?

I'm hoping this won't be too bad because all I'm interested in is just status updates and their time stamps. Eventually I'd like to pull other things like images and such, but for a first test just status updates is fine. Does anyone have sample code and/or pointers that could assist me in this endeavor?

如果有必要的话,如果有任何信息与 api 的当前版本(带有 oAuth 和 facebook 开放图的 Twitter)相关,我会很高兴.我见过的一些解决方案包括创建 twitter 应用程序和 facebook 应用程序来与 API 交互;如果我只想访问我自己的帐户信息的子集,那是否有必要?提前致谢!

I'd like it if any information relates to the current version of the apis (twitter with oAuth and facebook open graph) if they are necessary. Some solutions I've seen involve the creation of a twitter application and facebook application to interact with the APIs; is that necessary if all I want to do is access a subset of my own account information? Thanks in advance!

推荐答案

使用 cffeed 标签从 Twitter 和 Facebook 拉取 RSS 源.将最后一次提要扫描的日期保留在某处(应用程序变量或数据库)并遍历提要条目.任何比上次扫描更旧的条目都将被忽略,其他所有内容都将被提交.确保将 cffeed 包装在 try/catch 中,因为如果服务关闭,它会抛出错误(咳咳,推特)正如其他答案中提到的,将其设置为计划任务.

Use the cffeed tag to pull RSS feeds from Twitter and Facebook. Retain the date of the last feed scan somewhere (application variable or database) and loop over the feed entries. Any entry older than last scan is ignored, everything else gets committed. Make sure to wrap cffeed in a try/catch, as it will throw errors if the service is down (ahem, twitter) As mentioned in other answers, set it up as a scheduled task.

<cffeed action="read" properties="feedMetadata" query="feedQuery"
        source="http://search.twitter.com/search.atom?q=+from:mytwitteraccount" />

相关文章