List starred files 列出打星的文件
curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e6199b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/starredfiles/
def list_starred_files():
token = gettoken()
print len(token)
token='Token'+' '+token
print token
url = 'http://127.0.0.1:8000/api2/starredfiles/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization":token,"Accept":"application/json; indent=10","content-type":"application/json"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res
if __name__ == '__main__':
list_starred_files()
C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/mycompany/a8.py
{"token": "0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7"}
<type 'str'>
<type 'dict'>
0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7
40
Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7
{'content-type': 'application/json', 'Accept': 'application/json; indent=10', 'Authorization': u'Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7'}
[
{
"file_name": "u8bbeu7f6eu4f01u4e1au90aeu7bb1.DOC",
"icon_path": "word.png",
"oid": "db08bff6e3fccd447afe71e94d412cd65a669d49",
"mtime_relative": "<time datetime="2017-08-21T16:32:31" is="relative-time" title="Mon, 21 Aug 2017 16:32:31 +0800" >2 minutes ago</time>",
"repo": "afd1a8c0-bbd3-4c71-9068-0068585e7d98",
"org": -1,
"path": "/u8bbeu7f6eu4f01u4e1au90aeu7bb1.DOC",
"size": 956416,
"repo_id": "afd1a8c0-bbd3-4c71-9068-0068585e7d98",
"mtime": 1503304351,
"dir": false,
"repo_name": "u6211u7684u8d44u6599u5e93"
},
{
"file_name": "seafile-tutorial.doc",
"icon_path": "word.png",
"oid": "b88ab96740ef53249b9d21fb3fa28050842266ba",
"mtime_relative": "<time datetime="2017-08-15T14:52:00" is="relative-time" title="Tue, 15 Aug 2017 14:52:00 +0800" >6 days ago</time>",
"repo": "afd1a8c0-bbd3-4c71-9068-0068585e7d98",
"org": -1,
"path": "/seafile-tutorial.doc",
"size": 300544,
"repo_id": "afd1a8c0-bbd3-4c71-9068-0068585e7d98",
"mtime": 1502779920,
"dir": false,
"repo_name": "u6211u7684u8d44u6599u5e93"
}
]
Process finished with exit code 0
def list_starred_files():
token = gettoken()
print len(token)
token='Token'+' '+token
print token
url = 'http://127.0.0.1:8000/api2/starredfiles/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization":token,"Accept":"application/json; indent=10","content-type":"application/json"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
if __name__ == '__main__':
list_starred_files()
unicode 转成utf-8中文