My favorites | Sign in
Project Logo
          
Search
for
Updated Aug 18, 2009 by BunnyQ
Labels: Featured
ApiDocumentation  
饭否 API 文档

API更新记录

2009-06-20

2009-05-20

基本概念

用户验证

如需要验证用户,验证方式为 HTTP Basic 验证。

用户 id

用户 id 在个人网址中,例如:http://fanfou.com/fanfou 蓝色的部分即为用户 id。

使用 API 的简单途径

如果你的系统中有 cURL,就可以通过非常简单的方式使用这些API了。

示例:

  • 显示随便看看的消息
curl http://api.fanfou.com/statuses/public_timeline.rss
  • 显示用户消息
curl -u loginname:password http://api.fanfou.com/statuses/user_timeline.rss
  • 显示用户和好友的信息
curl -u loginname:password http://api.fanfou.com/statuses/friends_timeline.rss
  • 发布消息
curl -u loginname:password -d status="消息内容" http://api.fanfou.com/statuses/update.xml

API应用认证

通过认证的应用,在每条消息后会有 '通过 YOUR_APP_NAME' 的信息,YOUR_APP_NAME是你的应用名,并链接到应用的发布网址。

你的应用希望通过认证?请:

  1. 确保发新消息正确的传递了 source 参数(参考下面的 statuses update 方法)
  2. 请到饭否开发者论坛发帖,注明应用的source参数、应用名称、网址及简介。我们的工作人员将及时处理。

说明:

  • source参数请使用英文,source参数仅作为识别标志、不在网页上显示
  • 应用名称 将显示在网页上,也就是上文提到的YOUR_APP_NAME,建议使用中文

API 方法说明

消息相关的方法

显示随便看看的消息

路径: http://api.fanfou.com/statuses/public_timeline.[json|xml|rss]

参数:

示例: http://api.fanfou.com/statuses/public_timeline.rss?count=10
示例: http://api.fanfou.com/statuses/public_timeline.json?callback=getStatuses

显示用户和好友的消息

路径: http://api.fanfou.com/statuses/friends_timeline.[json|xml|rss]

参数:

示例: http://api.fanfou.com/statuses/friends_timeline.rss?id=fanfou
示例: http://api.fanfou.com/statuses/friends_timeline.rss?count=10
示例: http://api.fanfou.com/statuses/friends_timeline.xml?since_id=6IAZmgy1TzA
示例: http://api.fanfou.com/statuses/friends_timeline.xml?max_id=6IAZmgy1TzA
示例: http://api.fanfou.com/statuses/friends_timeline.json?page=3
示例: http://api.fanfou.com/statuses/friends_timeline.json?callback=getStatuses

显示用户的消息

路径: http://api.fanfou.com/statuses/user_timeline.[json|xml|rss]

参数:

示例: http://api.fanfou.com/statuses/user_timeline.rss?id=fanfouhttp://api.fanfou.com/statuses/user_timeline/fanfou.rss
示例: http://api.fanfou.com/statuses/user_timeline.rss?count=10
示例: http://api.fanfou.com/statuses/user_timeline.xml?since_id=6IAZmgy1TzA1
示例: http://api.fanfou.com/statuses/user_timeline.xml?max_id=6IAZmgy1TzA
示例: http://api.fanfou.com/statuses/user_timeline.json?page=3
示例: http://api.fanfou.com/statuses/user_timeline.json?callback=getStatuses

显示指定消息

路径: http://api.fanfou.com/statuses/show/id.[json|xml|rss]

参数:

示例: http://api.fanfou.com/statuses/show/6IAZmgy1TzA.xml

显示发给当前用户的消息

路径: http://api.fanfou.com/statuses/replies.[json|xml|rss]

参数:

示例: http://api.fanfou.com/statuses/replies.rss?count=10
示例: http://api.fanfou.com/statuses/replies.xml?since_id=6IAZmgy1TzA
示例: http://api.fanfou.com/statuses/replies.xml?max_id=6IAZmgy1TzA
示例: http://api.fanfou.com/statuses/replies.json?page=3

发布消息

路径: http://api.fanfou.com/statuses/update.[json|xml]

方法:POST

参数:

转发消息

转发 实际上是发布一条新消息,使用的是发布消息接口,我们推荐的实现是:

删除消息

路径: http://api.fanfou.com/statuses/destroy.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/statuses/destroy/6IAZmgy1TzA.xml

照片相关的方法New!

饭否上传API模拟HTML的file input上传照片,也就是 HTTP POST 时 Content-Type 设置为 multipart/form-data。参考RFC1867 http://www.ietf.org/rfc/rfc1867.txt

照片上传

路径:http://api.fanfou.com/photos/upload.[json|xml]

方法:POST

参数:

搜索相关的方法

公开搜索

路径:http://api.fanfou.com/search/public_timeline.[json|xml]

参数:

示例:http://api.fanfou.com/search/public_timeline.json?q=fanfouhttp://api.fanfou.com/search/public_timeline/%E9%A5%AD%E5%90%A6.xml,这里 %E9%A5%AD%E5%90%A6 是饭否的UTF8编码。
示例: http://api.fanfou.com/search/public_timeline/fanfou.xml?max_id=6IAZmgy1TzA

热词New!

返回当前的饭否热词。

路径:http://api.fanfou.com/trends.json

用户相关的方法

显示好友列表

路径: http://api.fanfou.com/users/friends.[json|xml]

参数:

示例: http://api.fanfou.com/users/friends.xml?id=fanfouhttp://api.fanfou.com/users/friends/fanfou.xml
示例: http://api.fanfou.com/users/friends.json?page=3

显示关注者列表

路径: http://api.fanfou.com/users/followers.[json|xml]

参数:

示例: http://api.fanfou.com/users/followers.xml?id=fanfouhttp://api.fanfou.com/users/followers/fanfou.xml
示例: http://api.fanfou.com/users/followers.json?page=3

显示用户详细信息

路径: http://api.fanfou.com/users/show.[json|xml]

参数:

示例: http://api.fanfou.com/users/show.xml?id=fanfouhttp://api.fanfou.com/users/show/fanfou.xml

私信相关的方法

显示用户收到的私信

路径: http://api.fanfou.com/direct_messages.[json|xml|rss]

参数:

示例: http://api.fanfou.com/direct_messages.xml?count=10
示例: http://api.fanfou.com/direct_messages.xml?since_id=12345
示例: http://api.fanfou.com/direct_messages.xml?max_id=6IAZmgy1TzA
示例: http://api.fanfou.com/direct_messages.json?page=3

显示用户发的私信

路径: http://api.fanfou.com/direct_messages/sent.[json|xml]

参数:

示例: http://api.fanfou.com/direct_messages/sent.xml?count=10
示例: http://api.fanfou.com/direct_messages/sent.xml?since_id=12345
示例: http://api.fanfou.com/direct_messages/sent.xml?max_id=6IAZmgy1TzA
示例: http://api.fanfou.com/direct_messages/sent.json?page=3

发送私信

路径: http://api.fanfou.com/direct_messages/new.[json|xml]

方法:POST

参数:

删除私信

路径: http://api.fanfou.com/direct_messages/destroy.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/direct_messages/destroy.xml?id=102http://api.fanfou.com/direct_messages/destroy/102.xml

收藏相关的方法

显示用户的收藏列表

路径: http://api.fanfou.com/favorites.[json|xml|rss]

参数:

示例: http://api.fanfou.com/favorites/fanfou.rsshttp://api.fanfou.com/favorites/fanfou.xml
示例: http://api.fanfou.com/favorites.xml?count=10
  • page (可选) - 页码,从 1 开始
示例: http://api.fanfou.com/favorites.json?page=3

收藏某条消息

路径: http://api.fanfou.com/favorites/create/id.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/favorites/create/VFL8jI1pl9c.json
http://api.fanfou.com/favorites/create/VFL8jI1pl9c.xml

删除收藏

路径: http://api.fanfou.com/favorites/destroy/id.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/favorites/destroy/VFL8jI1pl9c.jsonhttp://api.fanfou.com/favorites/destroy/VFL8jI1pl9c.xml

好友关系方法

添加好友

路径: http://api.fanfou.com/friendships/create.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/friendships/create.xml?id=fanfouhttp://api.fanfou.com/friendships/create/fanfou.xml

删除好友

路径: http://api.fanfou.com/friendships/destroy.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/friendships/destroy.xml?id=fanfouhttp://api.fanfou.com/friendships/destroy/fanfou.xml

判断好友关系是否存在New!

路径: http://api.fanfou.com/friendships/exists.[json|xml]

参数:

示例: http://api.fanfou.com/friendships/exists.xml?user_a=fanfou&user_b=wanhuai

好友和关注者方法New!

显示好友id列表

路径: http://api.fanfou.com/friends/ids.[json|xml]

参数:

示例: http://api.fanfou.com/friends/ids/fanfou.xml

显示关注者id列表

路径: http://api.fanfou.com/followers/ids.[json|xml]

参数:

示例: http://api.fanfou.com/followers/ids/fanfou.xml

好友消息通知方法New!

打开通知

路径: http://api.fanfou.com/notifications/follow.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/notifications/follow.xml?id=fanfouhttp://api.fanfou.com/notifications/follow/fanfou.xml

关闭通知

路径: http://api.fanfou.com/notifications/leave.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/notifications/leave.xml?id=fanfouhttp://api.fanfou.com/notifications/leave/fanfou.xml

黑名单方法

加入黑名单

路径: http://api.fanfou.com/blocks/create.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/blocks/create.xml?id=fanfouhttp://api.fanfou.com/blocks/create/fanfou.xml

解除黑名单

路径: http://api.fanfou.com/blocks/destroy.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/blocks/destroy.xml?id=fanfouhttp://api.fanfou.com/blocks/destroy/fanfou.xml

账号方法

验证用户

检验用户名密码是否正确

路径: http://api.fanfou.com/account/verify_credentials.[json|xml]

参数:无

保存搜索相关的方法New!

显示登录用户的搜索保存列表

路径: http://api.fanfou.com/saved_searches.[json|xml]

显示指定的搜索词

路径: http://api.fanfou.com/saved_searches/show/id.[json|xml]

参数:

示例: http://api.fanfou.com/saved_searches/show/12345.xml

保存搜索词

路径: http://api.fanfou.com/saved_searches/create.[json|xml]

方法:POST

参数:

示例: curl -u user:password -d "query=fanfou" http://api.fanfou.com/saved_searches/create.xml

删除搜索词

路径: http://api.fanfou.com/saved_searches/destroy/id.[json|xml]

方法:POST

参数:

示例: http://api.fanfou.com/saved_searches/destroy/12345.jsonhttp://api.fanfou.com/saved_searches/destroy/12345.xml

辅助方法

测试API

用指定格式返回一个 ok 值,返回的 HTTP code 为 200

路径: http://api.fanfou.com/help/test.[json|xml]

参数:无

返回的参数模块

消息模块

消息模块由消息的信息组成,其中用一个用户模块来描述消息的发起人

<status>
<created_at>
<id>
<text>
<source>
<truncated>
<in_reply_to_status_id>
<in_reply_to_user_id>
<favorited>
<in_reply_to_screen_name>
<photo_url>
<user>
<id>
<name>
<screen_name>
<location>
<description>
<profile_image_url>
<url>
<protected>
<followers_count>

用户基本信息模块

用户基本信息模块由用户的基本信息组成,其中用一个消息模块来描述此用户最新的一条消息

<user>
<id>
<name>
<screen_name>
<location>
<description>
<profile_image_url>
<url>
<protected>
<followers_count>
<status>
<created_at>
<id>
<text>
<source>
<truncated>
<in_reply_to_status_id>
<in_reply_to_user_id>
<favorited>
<in_reply_to_screen_name>

用户扩展信息模块

用户扩展信息模块,较详细的表示了用户的各项信息。(以后还会继续补充)

<user>
<id>
<name>
<screen_name>
<location>
<description>
<profile_image_url>
<url>
<protected>
<friends_count>
<followers_count>
<favourites_count>
<statuses_count>
<created_at>
<following>
<notifications>
<utc_offset>

私信模块

私信模块由私信的各项属性组成,其中由sender模块表示发信人信息,recipient模块表示收信人信息

<direct_message>
<id>
<text>
<sender_id>
<recipient_id>
<created_at>
<sender_screen_name>
<recipient_screen_name>
<sender>
<id>
<name>
<screen_name>
<location>
<description>
<profile_image_url>
<url>
<protected>
<followers_count>
<recipient>
<id>
<name>
<screen_name>
<location>
<description>
<profile_image_url>
<url>
<protected>
<followers_count>

返回的参数属性值

created_at

描述: 元素的创建时间

示例: Fri Apr 10 12:59:35 +0000 2009

description

描述: 用户的自述

示例: 默认值为空

favorited

描述: 表示当前消息是否已被收藏

示例: true, false

favorites_count

描述: 当前用户的收藏数

示例: 0, 268

following

描述: 表示被验证用户是否已经把当前用户加为好友了

示例: true, false

followers_count

描述: 当前用户的被关注数

示例: 0, 2013

friends_count

描述: 当前用户的好友数

示例: 0, 801

name

描述: 当前用户的昵称

示例: 饭否, 郭万怀

id

描述: 元素的独立id

示例: 4L0aUggHfq8 (消息id), fanfou (用户id)

in_reply_to_screen_name

描述: 消息所回复的用户昵称

示例: (空值), 饭否

in_reply_to_status_id

描述: 被回复的消息id

示例: (空值), 4L0aUggHfq8

in_reply_to_user_id

描述: 消息所回复的用户id

示例: (空值), fanfou

location

描述: 用户的所在地

示例: 北京, 上海

notifications

描述: 表示被验证的用户是否接收当前用户的消息通知

示例: true, false

profile_image_url

描述: 当前用户的头像地址

示例:

protected

描述: 表示当前用户是否设置了“需要我批准才能查看我的消息”

示例: true, false

screen_name

描述: 当前用户的昵称

示例: 饭否, 郭万怀

source

描述: 消息的发布途径

示例: 网页, 手机上网

statuses_count

描述: 当前用户的消息数

示例: 0, 2068

text

描述: 消息的内容

示例: 饭否排行榜新增最新动态,可以看到刚刚给自己打过标签的人。

truncated

描述: 表示当前消息是否需要截断

示例: true, false

url

描述: 用户个人信息中的网站地址

示例: h​t​t​p​:​/​/​d​e​v​.​f​a​n​f​o​u​.​c​o​m

意见反馈

请访问饭否开发者论坛

Hosted by Google Code