阿里妈妈佣金转换API接口(阿里妈妈返佣接口,淘宝客佣金接口,淘宝链接转换接口)代码对接教程

阿里妈妈佣金转换API接口(阿里妈妈返佣接口,淘宝客佣金接口,淘宝链接转换接口,淘宝佣金转换接口)代码对接教程如下:

1.公共参数

名称 类型 必须 描述
key String 调用key(必须以GET方式拼接在URL中,点击获取请求key和secret
secret String 调用密钥
api_name String API接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等]
cache String [yes,no]默认yes,将调用缓存的数据,速度比较快
result_type String [json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读
lang String [cn,en,ru]翻译语言,默认cn简体中文
version String API版本

2.请求参数(接口代码教程wx19970108018)

请求参数:id=40948381564&pid=mm_1409800143_2028300495_110837200055&tbname=oneboundcn&hasiteminfo=&extsearch=&tpwd=&shorturl=

参数说明:*id:淘宝天猫的商品ID
*pid:pid
*tbname:淘宝昵称
hasiteminfo:是否输出商品信息,双十一期间不建议启用,1=启用,0=不启用
extsearch:官方查不到券时是否去第三方平台查询,1为启用
tpwd:是否生成淘口令,1为生成,不填则不生成
shorturl:是否需要短链接,1为生成,不填则不生成 

3.响应参数

4.请求示例(CURL、PHP 、PHPsdk 、Java 、C# 、Python…) 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.charset.Charset;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.PrintWriter;
import java.net.URLConnection;

public class Example {
	private static String readAll(Reader rd) throws IOException {
		StringBuilder sb = new StringBuilder();
		int cp;
		while ((cp = rd.read()) != -1) {
			sb.append((char) cp);
		}
		return  sb.toString();
	}
	public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException {
		URL realUrl = new URL(url);
		URLConnection conn = realUrl.openConnection();
		conn.setDoOutput(true);
		conn.setDoInput(true);
		PrintWriter out = new PrintWriter(conn.getOutputStream());
		out.print(body);
		out.flush();
		InputStream instream = conn.getInputStream();
		try {
			BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
			String jsonText = readAll(rd);
			JSONObject json = new JSONObject(jsonText);
			return json;
		} finally {
			instream.close();
		}
	}
	public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException {
		URL realUrl = new URL(url);
		URLConnection conn = realUrl.openConnection();
		InputStream instream = conn.getInputStream();
		try {
			BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
			String jsonText = readAll(rd);
			JSONObject json = new JSONObject(jsonText);
			return json;
		} finally {
			instream.close();
		}
	}
	public static void main(String[] args) throws IOException, JSONException {
		// 请求示例 url 默认请求参数已经URL编码处理
		String url = "https://wx19970108018/alimama/item_id/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&id=40948381564&pid=mm_1409800143_2028300495_110837200055&tbname=oneboundcn&hasiteminfo=&extsearch=&tpwd=&shorturl=";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}

猜你喜欢

转载自blog.csdn.net/Andyfu2019/article/details/126604782