ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

脚本内网络访问工具curl

2022-08-12 01:00:21  阅读:216  来源: 互联网

标签:脚本 v1 访问 token https curl com id


以上传谷歌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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有