C#如何调用php网站的api接口

GragonBoy 2011-11-22 02:28:03
如下为文档的一部分
1、接口地址URL地址为网痁URL+api.php 如 www.abc.com/api.php
2、接入方式:POST
3、接入类型:系统调用
4、接口方法一:
[/img]
5、验证机制,签名验证
串联需要POST的值+ 中心会话密钥进行Md5(编码为32位位长)编码构成了相应的校验码,记入POST[‘ac’]中和相应的POST值一起传送到服务器.
如:
系统参数:$token 中心会话密钥
业务数据:
$_POST[‘username’]=’user’ $_POST[‘password’]=’password’
Ksort($_POST);(以数据的Key作为健对数据进行升序排列)
$verify=’’;
foreach($_POST as $key=>$value){
$verify.= $value;
}
则:$_POST[‘ac’]=md5($verify. $token); 

请教各位大侠如何调用这个接口
...全文
544 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
GragonBoy 2011-11-23
  • 打赏
  • 举报
回复
还有没有其他答案呀?
宝_爸 2011-11-22
  • 打赏
  • 举报
回复
下面代码来自
http://www.jigar.net/howdoi/viewhtmlcontent106.aspx


poststring 是要post的数据

void PostMe(object sender, EventArgs e){
string poststring = String.Format("field1={0}&field2={1}",text1.Text,text2.Text);
ResponseResult.Text = "<hr/>" +
GetResponseString("http://www.jigar.net/demo/HttpRequestDemoServer.aspx",poststring);
}

String GetResponseString(string url, string poststring){
HttpWebRequest httpRequest =
(HttpWebRequest)WebRequest.Create("http://www.jigar.net/demo/HttpRequestDemoServer.aspx");

httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";

byte[] bytedata = Encoding.UTF8.GetBytes(poststring);
httpRequest.ContentLength = bytedata.Length;

Stream requestStream = httpRequest.GetRequestStream();
requestStream.Write(bytedata, 0, bytedata.Length);
requestStream.Close();


HttpWebResponse httpWebResponse =
(HttpWebResponse)httpRequest.GetResponse();
Stream responseStream = httpWebResponse.GetResponseStream();

StringBuilder sb = new StringBuilder();

using (StreamReader reader =
new StreamReader(responseStream, System.Text.Encoding.UTF8))
{
string line;
while ((line = reader.ReadLine()) != null)
{
sb.Append(line);
}
}

return sb.ToString();

}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧