其他分享
首页 > 其他分享> > 脚本内网络访问工具curl

脚本内网络访问工具curl

作者:互联网

以上传谷歌PAI配置为例。

1.获得身份验证:tokenid

2.获得PAI内的apk配置在谷歌的暂存区key:sessionid

3.获得productid并和需要配置的数据组成 configString

4.上传apk并获取回传结果

5.save拼好的configString到PAI网站

6.发布PAI网站对应product的所有配置

 1 rem bat脚本和shell脚本中都可以使用curl语句来进行网络访问,且语法结构相同,但其中变量调用方式会因脚本不同而不同。如下使用一行bat一行shell进行对比。
 2 rem 如获取谷歌tokenid的语句
 3 curl -i -k -s -X POST --data "client_id=%client_id%&client_secret=%client_secret%&refresh_token=%refresh_token%&grant_type=refresh_token" https://accounts.google.com/o/oauth2/token > tokenid_result.txt
 4 curl -i -k -s -X POST --data "client_id=${client_id}&client_secret=${client_secret}&refresh_token=${refresh_token}&grant_type=refresh_token" https://accounts.google.com/o/oauth2/token > 
 5 tokenid_result.txt
 6 rem 如获取谷歌sessionid的语句
 7 curl -i -k -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer %token_id%" -H "X-GFE-SSL: yes" -d "" https://androidpartner.googleapis.com/v1/playAutoInstalls:startUploadApk > sessionid_result.txt
 8 curl -i -k -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token_id" -H "X-GFE-SSL: yes" -d "" https://androidpartner.googleapis.com/v1/playAutoInstalls:startUploadApk > sessionid_result.txt
 9 rem 如获取谷歌productId的语句
10 curl -i -k -s -X GET -H "Authorization:Bearer %token_id%" "https://androidpartner.googleapis.com/v1/compatibility/devices/%devicename%/products/%productname%/builds" > productId_result.txt
11 curl -i -k -s -X GET -H "Authorization:Bearer ${token_id}" "https://androidpartner.googleapis.com/v1/compatibility/devices/${devicename}/products/${productname}/builds" > 
12 productId_result.txt
13 rem 如上传谷歌PAIfile的语句
14 curl -i -k -X POST -H "Authorization: Bearer %token_id%" -T "%paiFilePath%" "https://androidpartner.googleapis.com/upload/v1/media/%session_id%?upload_type=media" > paifile_uploadresult.txt
15 curl -i -k -X POST -H "Authorization: Bearer $token_id" -T "$paifile" "https://androidpartner.googleapis.com/upload/v1/media/${session_id}?upload_type=media" >
16 paifile_uploadresult.txt
17 rem 如上传谷歌PAIconfig的语句
18 curl -i -k -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer %token_id%" -H "X-GFE-SSL: yes" -d "%playautoinstallconfigStr%" "https://androidpartner.googleapis.com/v1/playAutoInstalls?apkRef=%session_id%" > paiconfig_uploadresult.txt
19 curl -i -k -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token_id" -H "X-GFE-SSL: yes" -d "{config:{$playautoinstallconfigStr}}" "https://androidpartner.googleapis.com/v1/playAutoInstalls?apkRef=${session_id}" > 
20 paiconfig_uploadresult.txt
21 rem 如publish当前productid的所有刚刚save的谷歌PAIconfig(+PAIfile)的语句
22 curl -i -k -X POST -H "Content-Type: application/json" -H "Authorization: Bearer %token_id%" -H "X-GFE-SSL: yes" -d "" "https://androidpartner.googleapis.com/v1/playAutoInstalls/%productId%:publish" > paiconfig_publishresult.txt
23 curl -i -k -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token_id" -H "X-GFE-SSL: yes" -d "" "https://androidpartner.googleapis.com/v1/playAutoInstalls/${product_id}:publish"

 

一开始的client_id等变量为合作者账户通过阅读谷歌网站并解析所得固定变量,大致如下:

附PAI配置相关的google网址
https://docs.partner.android.com/partners/guides/adcp/clientid/api
https://developers.google.com/android-partner/reference/rest/v1/playAutoInstalls#PlayAutoInstallConfig
https://developers.google.com/android-partner/reference/rest/v1/playAutoInstalls/create

标签:脚本,v1,访问,token,https,curl,com,id
来源: https://www.cnblogs.com/1118zjg/p/16009792.html