复制 curl -i http://www.zhipaiwu.cn/api.php/Jiance/execute -H 'Authorization:APPCODE 你自己的AppCode' -H 'Content-Type:application/octet-stream' --data '{"content":"base64_encode(内容)","appcode":"e72ce895a25127fbf60f4c482d8d7233492d3a92"}' -H 'Content-Type:application/json; charset=UTF-8'
复制 var unirest = require("unirest");
var req = unirest("POST", "http://www.zhipaiwu.cn/api.php/Jiance/execute");
req.query({"content":"base64_encode(内容)","appcode":"e72ce895a25127fbf60f4c482d8d7233492d3a92"});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
复制 public static void main(String[] args) {
String host = "";
String path = "";
String method = "POST";
String appcode = "你自己的AppCode";
Map headers = new HashMap();
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
headers.put("Authorization", "APPCODE " + appcode);
//根据API的要求,定义相对应的Content-Type
headers.put("Content-Type", "application/json; charset=UTF-8");
headers.put("Content-Type", "application/octet-stream");
Map querys = new HashMap();
querys.put("code", "2bdab410-71b7-4f6d-9b91-8db27c9197e4");
String bodys = '{"content":"base64_encode(内容)","appcode":"e72ce895a25127fbf60f4c482d8d7233492d3a92"}';
try {
/**
* 重要提示如下:
* HttpUtils请从
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
* 下载
*
* 相应的依赖请参照
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
*/
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
System.out.println(response.toString());
//获取response的body
//System.out.println(EntityUtils.toString(response.getEntity()));
} catch (Exception e) {
e.printStackTrace();
}
}
复制
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import requests
import base64
import json
url='http://www.zhipaiwu.cn/api.php/Jiance/execute'
appcode="XXXXXXXXXXXXXXXXXXXXX"
nrs="杨莉说,目前不少国家和地区都有自己的母亲节,影响最大的是起源于古希腊的西方母亲节,为每年5月的第二个星期日。泰国则以泰王后丽吉的生日(8月16日)为母亲节,印度尼西亚母亲节定在12月22日,阿拉伯地区的许多国家则将母亲节设立在3月21日。但是,我国尚未有法定"
nrs = base64.b64encode(nrs.encode())
#bodys={}
bodys = {"appcode":appcode,"content":nrs}
#print(bodys)
r = requests.post(url,data=bodys)
dics = json.loads(r.text)
print(dics)
复制
$host = "";
$path = "";
$method = "GET";
$appcode = "你自己的AppCode";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "vin=LSVAL41Z882104202";
$bodys = '{"content":"base64_encode(内容)","appcode":"e72ce895a25127fbf60f4c482d8d7233492d3a92"}';
$url = $host . $path . "?" . $querys;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
if (1 == strpos("$".$host, "https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
var_dump(curl_exec($curl));
复制 //using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;
private const String host = " ";
private const String path = " ";
private const String method = "POST";
private const String appcode = "你自己的AppCode";
static void Main(string[] args)
{
String querys = "code=2bdab410-71b7-4f6d-9b91-8db27c9197e4";
String bodys = '{"content":"base64_encode(内容)","appcode":"e72ce895a25127fbf60f4c482d8d7233492d3a92"}';
String url = host + path;
HttpWebRequest httpRequest = null;
HttpWebResponse httpResponse = null;
if (0 < querys.Length)
{
url = url + "?" + querys;
}
if (host.Contains("https://"))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
}
else
{
httpRequest = (HttpWebRequest)WebRequest.Create(url);
}
httpRequest.Method = method;
httpRequest.Headers.Add("Authorization", "APPCODE " + appcode);
//根据API的要求,定义相对应的Content-Type
httpRequest.Headers.Add("Content-Type", "application/json; charset=UTF-8");
httpRequest.Headers.Add("Content-Type", "application/octet-stream");
if (0 < bodys.Length)
{
byte[] data = Encoding.UTF8.GetBytes(bodys);
using (Stream stream = httpRequest.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}
try
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
}
catch (WebException ex)
{
httpResponse = (HttpWebResponse)ex.Response;
}
Console.WriteLine(httpResponse.StatusCode);
Console.WriteLine(httpResponse.Method);
Console.WriteLine(httpResponse.Headers);
Stream st = httpResponse.GetResponseStream();
StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("\n");
}
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
复制 require 'uri'
require 'net/http'
url = URI("http://www.zhipaiwu.cn/api.php/Jiance/execute")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
复制 #import <Foundation/Foundation.h>
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://apis.zhipaiwu.cn/efficient/vinservice?vin=LSGPC52U6AF102554&key=your_AppKey"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
复制 package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "http://apis.zhipaiwu.cn/efficient/vinservice?vin=LSGPC52U6AF102554&key=your_AppKey"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
复制 import Foundation
var request = NSMutableURLRequest(URL: NSURL(string: "http://apis.zhipaiwu.cn/efficient/vinservice?vin=LSGPC52U6AF102554&key=your_AppKey")!,
cachePolicy: .UseProtocolCachePolicy,
timeoutInterval: 10.0)
request.HTTPMethod = "GET"
let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
println(error)
} else {
let httpResponse = response as? NSHTTPURLResponse
println(httpResponse)
}
})
dataTask.resume()
复制 var settings = {
"async": true,
"crossDomain": true,
"url": "http://apis.zhipaiwu.cn/efficient/vinservice?vin=LSGPC52U6AF102554&key=your_AppKey",
"method": "GET",
"headers": {}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
复制 var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "http://apis.zhipaiwu.cn/efficient/vinservice?vin=LSGPC52U6AF102554&key=your_AppKey");
xhr.send(data);
复制 var client = new RestClient("http://apis.zhipaiwu.cn/efficient/vinservice?vin=LSGPC52U6AF102554&key=your_AppKey");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
复制 open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "http://apis.zhipaiwu.cn/efficient/vinservice?vin=LSGPC52U6AF102554&key=your_AppKey" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
复制 CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "http://apis.zhipaiwu.cn/efficient/vinservice?vin=LSGPC52U6AF102554&key=your_AppKey");
CURLcode ret = curl_easy_perform(hnd);