通過豆瓣api可以獲取很多電影、書籍等的數(shù)據(jù)信息。昨晚上用微信小程序請求豆瓣api,竟然被豆瓣拒絕了。(豆瓣設(shè)置了小程序的訪問權(quán)限)。 onLoad: function (options) { this.getMoviesData('https://api.douban.com/v2/book/1220562') }, getMoviesData:function(url){ wx.request({ url: url, data: {}, method: 'GET', header: { 'content-type': 'application/json' }, success: function (res) { console.log(res) }, fail: function () { console.log('fail') }, }) }
location /v2/ { proxy_store off; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Referer 'no-referrer-when-downgrade'; proxy_set_header User-Agent 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; proxy_pass https://api.douban.com/v2/; }
onLoad: function (options) { this.getMoviesData('http://localhost/v2/book/1220562') }, getMoviesData:function(url){ wx.request({ url: url, data: {}, method: 'GET', header: { 'content-type': 'application/json' }, success: function (res) { console.log(res) }, fail: function () { console.log('fail') }, }) }
竟然還是錯誤!?。?/p>
onLoad: function (options) { this.getMoviesData('http://localhost/v2/book/1220562') }, getMoviesData:function(url){ wx.request({ url: url, data: {}, method: 'GET', header: { 'content-type': 'application/xml' }, success: function (res) { console.log(res) }, fail: function () { console.log('fail') }, }) } |
工作日 8:30-12:00 14:30-18:00
周六及部分節(jié)假日提供值班服務(wù)