淘宝API的使用例子
http://hi.baidu.com/kalada/item/b1b498279028921409750866
首先,在我的工作台-》注册软件,获得APP_ID和CERT_CODE,在管理我的软件里,录入软件测试URL,我这里举例http://localhost:2715/RestTest/Default.aspx。
然后,本地系统里编写接口调用代码,下面是我的举例系统内Default.aspx.cs调用代码
阅读(4306) | 评论(0) | 转发(1) |
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
建议PHP开发者使用JSON,因为PHP5对JSON有很好的支持。
以下是对taobao.shopcats.list.get接口调用实例。
API官方文档在这里:
http://isv.alisoft.com/isv/html/showhtml.jspa?html=/html/taobao/api/taobao.shopcats.list.get.html
/**
* 淘宝API调试
*/
function getCats(){
res = res));
}
public function taobao_getCates(v = '1.0', $sip_format = 'json'){.NET调用validateUser接口举例(代码) 这里对.NET如何调用互联平台接口通过举例做下介绍。
timestamp = date("Y-m-d H:i:s");//'2008-05-02 21:18:58';
formVars['sip_timestamp'] = formVars['sip_appkey'] = formVars['sip_apiname'] = 'taobao.shopcats.list.get';
v;
parent_cid;
sip_sessionid;
sip_format;
ksort(formVars);
//生成签名
this->CERT_CODE;
foreach (key => sip_sign = strtoupper(md5(formVars['sip_sign'] = proxy->submit(formVars);
return ($proxy->results);
}
首先,在我的工作台-》注册软件,获得APP_ID和CERT_CODE,在管理我的软件里,录入软件测试URL,我这里举例http://localhost:2715/RestTest/Default.aspx。
然后,本地系统里编写接口调用代码,下面是我的举例系统内Default.aspx.cs调用代码
protected void Page_Load(object sender, EventArgs e)最后,启本地应用服务,在管理我的软件里点“测试软件”按钮,就可以登录到自己的应用服务,并且成功调用了互联平台上的验证用户接口哦。
{
HttpRequest request = HttpContext.Current.Request;
//在软件应用中心跳转到ISV应用时的URL参数中取得,user_id、app_instance_id和token
string aepUserId = request.Params["user_id"];
string aepInstanceId = request.Params["app_instance_id"];
string appId = request.Params["app_id"]; //软件注册时获得
string token = request.Params["token"]; //每次点击生成不一样的token,并只有10秒钟有效
string code = "6c0a91f01a5411dd8179bad18f04aace";//软件注册时获得
System.DateTime timestamp = System.DateTime.Now;//时间获得当前系统时间
//sip_sign签名字段的生成,将CERT CODE和所有接口要传的参数进行组合,再将组装好的字符串进行md5加密后转成16进制后得到一个32位的密文
string sipsign = code + "appId" + appId + "appInstanceId" + aepInstanceId + "sip_apinamealisoft.validateUser" + "sip_appkey" + appId + "sip_timestamp" + timestamp + "token" + token + "userId" + aepUserId;
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
sipsign =BitConverter.ToString( md5.ComputeHash(Encoding.UTF8.GetBytes(sipsign))).Replace("-","");
//sip_sign生成END
//系统级参数拼装,包括sip_appkey、sip_apiname、sip_timestamp和sip_sign,sip_apiname是接口名这里举validateUser为例
string SIPdate = "sip_appkey=" + appId + "&sip_apiname=alisoft.validateUser&sip_timestamp="+timestamp+"&sip_sign="+sipsign;
//接口级参数拼装
string apidate="&userId="+aepUserId+"&appId="+appId+"&appInstanceId="+aepInstanceId+"&token="+token;
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] postdata =encoding.GetBytes(SIPdate + apidate);//所有要传参数拼装
// Prepare web request...
//目前阿里软件的服务集成平台(SIP)的接口测试地址是:http://sipdev.alisoft.com/sip/rest,生产环境地址是:http://sip.alisoft.com/sip/rest,
//这里使用测试接口先,到正式上线时需要做切换
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://sipdev.alisoft.com/sip/rest");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = postdata.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(postdata, 0, postdata.Length);
newStream.Close();
// Get response
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string content = reader.ReadToEnd();
//解析接口返回值,这里选用XML格式的解析,接口默认返回是XML格式
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(content);
XmlNode xn = xmlDoc.SelectSingleNode("String");
XmlElement xe = (XmlElement)xn;
string result = xe.InnerText;
if ("1".Equals(result))
{
//如果是使用者。。。。
windowalert("使用者");
}
else if ("0".Equals(result))
{
//如果是订阅者。。。。
windowalert("订阅者");
}
}
private void windowalert(string str)
{
HttpResponse Response = HttpContext.Current.Response;
Response.Write("<script>alert('" + str + "');window.close(true);</script>");
}
}
相关热门文章
给主人留下些什么吧!~~
评论热议
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通