日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

超媒体API

發(fā)布時(shí)間:2024/4/13 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 超媒体API 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

curl https://api.github.com

超媒體API的目標(biāo)之一,是讓客戶端在不重新便編寫代碼的前提下動(dòng)態(tài)調(diào)整所用的端點(diǎn)。

使用jq可以在命令行中解析JSON

jq安裝方式

os系統(tǒng)可以用brew

brew install jq

示例用法:
curl https://api.github.com | jq '.current_user_url'?
curl -s https://api.github.com/users/xrd/repos | jq '.[0].owner.id'

cURL的調(diào)試開關(guān)

使用? -i 開關(guān)打印請(qǐng)求頭部
curl -i https://apis.github.com

使用 -v開關(guān)請(qǐng)求和響應(yīng)首部
curl -v https://apis.github.com

使用條件請(qǐng)求規(guī)避頻率限制

If-Modified-Since (對(duì)應(yīng)時(shí)間) 和 If-None-Match(對(duì)應(yīng)ETag)

curl -i https://api.github.com/repos/twbs/bootstrap -H "If-Modified-Since: Sun, 11 Aug 2013 19:48.59 GMT"

curl -i https://api.github.com/repos/twbs/bootstrap -H 'If-None-Match: "dd05e06d7110bed317b80f8dc2cabf6d"'

JSON-P例子

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title> </head><body><script>function myCallBack(payload) {console.log('payload', payload);}</script><script src="https://api.github.com/?callback=myCallBack"></script></body></html>

?

指定響應(yīng)的內(nèi)容格式

URL='https://api.github.com/repos/rails/rails/issues/11819' curl -s $URL | jq '.body' curl -s $URL | jq '.body_html' curl -s $URL H "Accept: application/vnd.github.html+json" | jq '.body_html'

?

轉(zhuǎn)載于:https://my.oschina.net/lilugirl2005/blog/3044771

總結(jié)

以上是生活随笔為你收集整理的超媒体API的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。