{
"refresh_token": "25.b55fe1d287227ca97aab219bb24908ab.315360000.1798
284651.282335-8574074",
"expires_in": 2592000,
"scope": "public wise_adapt",
"session_key": "9mzdDZXu3dENdEZQurfgOVz8s1gSgvvOAUebNFzyzcp05EnbxbF+hfG9DQkpUVQdh4p6HbQcAiz5RmuBAjalJJGgIdJI",
"access_ token": "24.6c5e1ff107f0e8bcef8c46d3424a0e78.2592000.1485516651.282335-8574074",
"session_secret": "dfac94a3489fe9fca7c3221cbf7525ff"
}
{
"error": "invalid_client",
"error_description": "unknown client id"
# encoding: utf-8
import requests
host = 'https:
response = requests.get(host)
if response:
print(response.json())
# encoding:utf-8
import requests
import base64
request_url = "https://aip.baidubee.com/rest/2.0/image-classiEy/v1/car"
f = open('[本地文件]', 'rb')
img = base64.b64encode (f. read ())
params = {"image":img,"top_num":5}
access_token= '[调用鉴权接口获取的 token]'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-ur1encoded'}
response = requests.post(request_url, data=params, headers=headers)
if response:
print (response.json ())
返回的 JSON 数据:
{
"log_id”: 4086212218842203806,
"location_result": {
"width": 447,
"top": 226,
"height": 209,
"left": 188
},
"result":[{
"baike_info": {
"baike_url: "http://baike.baidu.com/iten/E5%B8%83%5%82%A08E8BFAAchiron/20419512",
"description":"布加迪 Chiron 是法国跑车品牌布加迪出品的豪华超跑车。配置四涡轮
增压发动机,420 公里每小时,有23种颜色的选择。售价高达 260万美元。"
},
"score": 0.98793351650238,
"name”:" 布加迪 Chiron",
"year":"无年份信息"
},
{
"score": 0.0021970034576952,
"name":"奥迫RS5",
"year": "2011-2017"
},
{
"score": 0.0021096928976476,
"name": "奥迪RS4",
"year": "无年份信息"
},
{
"score": 0.0015581247862428,
"name": "奥迪RS7",
"year": "2014-2016"
},
{
"score": 0.00082337751518935,
"name": "布加迪威航",
"year": "2004-2015"
}],
"color_result": "颜色无法识别"
}
{
"Name": "Chen Zhifeng",
"Profession": "Teacher",
"Age": 46,
"Email": "13402506301@163.con",
"Eriends" : InZhang San", "Li si"]
}
{
"TeamName":"i0S-Orange-Team",
"Teacher": "Chen Zhifeng",
"Students": [
{ "Name": "Zhang Bo","Hometown": "Xuzhou"'},
{"Name": " Chang Wenxiang ", "Hometown": "Yancheng"),
{"Name" :" Hu Yinting". "Hometown": "Suzhou"}
]
}
{
"coord": ("lon": -0.13, "lat": 51.51},
"weather": ("id": 300, "main": "Drizzle", "description": "light
intensity drizzle", "icon": "09d"} ],
"base":"stations"
"main": {
"temp": 280.32,
"pressure": 1012,
"humidity": 81,
"temp min":279.15,
"temp_max":281.15
},
"visibility": 10000,
"wind": ("speed": 4.1, "deg": 801},
"clouds": ("all": 90},
"dt": 1485789600,
"sys": {
"type": 1,
"id": 5091,
"message": 0.0103,
"country": "GB",
"sunrise" :1485762037
"sunset": 1485794875
},
"id": 2643743,
"name": "London",
"cod":200
}
# myjson. js
module.exports = function () {
var data = f users: [] }
for (var i = 0; i < 1000; i++) {
data .users .push (f id: i, name: 'user' +i })
}
return data
}
# news .Js
let Mock = require ('mockjs');
let Random = Mock. Random;
module.exports = function () {
var data = {
news: []
};
var images = [1,2,3] .map (×=>Random. image ('200×100', Random. color (),
Random. word (2, 5)));
for (var i = 0; i < 100; i++) {
var content - Random. cparagraph (0,10) ;
data.news.push ( {
id: i,
title: Random.cword (8,20),
desc: content.substr (0,40) ,
tag: Random.cword (2,6) ,
views: Random.integer (100,5000),
images: images.slice (0, Random. integer (1,3) )
})
}
return data
}
imoort UIKit
import Foundation
if let url = URL (string: "http: / /1ocalhost:3004/news") {
JRISession. shared. dataTask (with: url) t(datar response, error) in
if error != nil (
print ("Network errors")
}
else {
let rs = String (data: data!, encoding: String. Encoding.utf8) !
print (rs)
if let json = try? JSONSerialization. jsonObject (with: data!,
options: .allowFragments) }
print(json)
}
}
}
.resume()
}