










1、線下付款,獲取可上傳圖片次數(shù) 2、申請請求接口所需的third_code和secret_key 3、根據(jù)接口文檔,接入服務(wù)
1、按照圖片上傳次數(shù)扣費,上傳失敗不扣費 2、獲取到的secret_key請妥善保管,不可外傳 3、所有修復(fù)成功的圖片本站將保留1小時后自動刪除,如需持久化存儲請下載至自有系統(tǒng)
1、code=200固定為成功,code=9000固定為失敗 2、code=9000時,如需進一步業(yè)務(wù)判斷,可根據(jù)errno參數(shù) 接口url:http://sdkphoto.fangtangtv.com
URL /api/third/photo/upload Method POST Header token: 加密生成的token,加密規(guī)則見附1 Params field type required commit third_code string Y 線下申請的第三方標(biāo)識third_code repair_type string Y sr:超分,sr;repair:超分+修復(fù);sr,repair,colour:超分+修復(fù)+上色;bg:證件照換底色 file file Y 上傳的文件file rgb string N 當(dāng)repair_type=bg時必傳,色值格式:255,255,255(代表白色)
curl --location --request POST 'XXXXXX/api/third/photo/upload' \ --header 'token: XXXXX' \ --form 'repair_type="bg"' \ --form 'third_code="XXXXXX"' \ --form 'file=@"/Users/max/Downloads/7c7a7c7964e02f022c6e7aeae12c8786.jpg"' \ --form 'rgb="255,255,255"'
field commit
img_url 上傳圖片的url
mdf 圖片的唯一標(biāo)識
{
"code": 200,
"data": {
"img_url": "https://photo.fangtangtv.com/static/img/6720978a-b256-49fc-b717-81efe6e298d8_out.jpg",
"mdf": "40b37f58db153e5149f008421797714e"
}
}
errno commit
9999 請求參數(shù)token不合法
9101 剩余下載次數(shù)為0
9001 傳入?yún)?shù)錯誤
9005 文件上傳類型不支持
9006 上傳失敗
9009 圖片異常,處理失敗
{
"code": 9000,
"errno": 9005,
"msg": "文件上傳類型不支持"
}URL /api/third/photo/status Method POST Header token: 加密生成的token,加密規(guī)則見附1 Params field type required commit third_code string Y 線下申請的第三方標(biāo)識third_code mdf string Y 文件唯一標(biāo)識
curl --location --request POST 'XXXXXX/api/third/photo/status' \ --header 'token: XXXXX' \ --form 'mdf="XXXXX"' \ --form 'third_code="XXXX"'
field commit
msg 描述
status 100:圖片處理中;200:圖片處理完成
{
"code": 200,
"data": {
"msg": "圖片處理完成",
"status": 200
}
}
errno commit
9002 圖片不存在
500 其他錯誤
{
"code": 9000,
"errno": 9002,
"msg": "圖片不存在,請確認圖片是否上傳成功"
}
URL /api/third/photo/download Method POST Header token: 加密生成的token,加密規(guī)則見附1 Params field type required commit third_code string Y 線下申請的第三方標(biāo)識third_code mdf string Y 文件唯一標(biāo)識
curl --location --request POST 'XXXXX/api/third/photo/download' \ --header 'token: XXXXX' \ --form 'mdf="XXXXX"' \ --form 'third_code="XXXXX"'
field commit
url 圖片下載地址
{
"code": 200,
"data": {
"url": "https://photo.fangtangtv.com/static/life_img/40b37f58db153e5149f008421797714e01100.jpg"
}
}
errno commit
9002 圖片不存在
500 其他錯誤
{
"code": 9000,
"errno": 9002,
"msg": "數(shù)據(jù)已失效,請重新上傳"
}
URL /api/third/company/nums Method POST Header token: 加密生成的token,加密規(guī)則見附1 Params field type required commit third_code string Y 線下申請的第三方標(biāo)識third_code
curl --location --request POST 'XXXXX/api/third/company/nums' \ --header 'token: XXXXX' \ --form 'third_code="XXXXX"'
field commit
code 第三方標(biāo)識third_code
nums 剩余上傳次數(shù)
{
"code": 200,
"data": {
"code": "hiliad",
"nums": 98
}
}
errno commit
9002 數(shù)據(jù)未找到
500 其他錯誤
{
"code": 9000,
"errno": 9002,
"msg": "數(shù)據(jù)未找到"
}1、拿到服務(wù)方提供的secret_key,再生成一個當(dāng)前時間戳time
secret_key = 'hiliad'
time = '1629962357'
2、secret_key + time,兩字符串拼接,再md5,得到參數(shù)mds
mds = hashlib.md5((secret_key + time).encode("utf8")).hexdigest()
mds = '5484490c8e797dabe52af90ab8bd1e50'
3、最終的token等于 mds + ',' + time
token = '5484490c8e797dabe52af90ab8bd1e50,1629962357'
注:生成的時間戳?xí)?分鐘后失效,請每次請求接口都重新生成時間戳