1.Linux curl命令:
curl --request POST --url https://10.132.43.101/auth/accesstoken --header 'cache-control: no-cache' --header 'content-type: application/json' --data '{ "appId": appId, "appSecret": "appSecret"}'
curl https://10.132.43.101/auth/accesstoken -X POST -d '{ "appId": appId, "appSecret": "appSecret"}' --header 'content-type: application/json'
2.Python代码执行
#! /usr/bin/python
# -*- coding: utf-8 -*-
import requests
headers = {
Content-Type:application/json
}
data={"appId": appId, "appSecret": "appSecret"}
response = requests.post("https://10.132.43.101/auth/accesstoken",headers=headers ,data=data)
3.JAVA代码执行curl命令
String[] cmds = {"curl","https://10.132.43.101/auth/accesstoken","-X","POST","--header","content-type: application/json","-d","{}"}
public static execCurl(String[] cmds){
ProcessBuilder process = new ProcessBuilder (cmds);
Process p = null;
try{
p = process.start();
BufferedReader readr = new BufferedReader(new InputStreamReader(p.getInputStream())));
StringBuilder builder = new StringBuilder();
String line;
while((line = reader.readLine()!=null)){
builder.append(line);
}
reader.close();
return builder.toString();
}catch(IoException){
}
}