Delphi中如何通过http get方式来调用url ?
API接口使用HTTP协议,可接受HTTPGET 和HTTPPOST访问。
参数传递方式为application/x-www-url-encoded,编码方式为UTF-8,且须遵循URL 编码规范
(RFC3986)对保留字符进行百分号编码。
操作结果返回方式为XML,编码方式为UTF-8。
接口地址:
http://api.123.com/XMLHttpService.do
比如使用 API 创建域名,假设已有一个模板 ID 为 10,使用此模板注册一域名 456.com,注册一年,
以下是以HTTPGET方式调用 API的URL:
http://api.123.com/XMLHttpService.do?username=test@namemax.cn&password=888888&command=re
gisterDomainName&domainName=456.om&period=1&templateId=10
URL中的username paeeword command domainname period templateId都是参数
请问如何使用Delphi的http get 调用url,并返回?需要加什么控件?最好给出完整的代码。
若操作成功,服务器将返回以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<command>registerDomain</command>
<result>SUCCESSFUL</result>
<data>
<domain>456.com</domain>
<creationDate>2008-06-22 08:38:00</creationDate>
<expirationDate>2009-06-21 08:38:00</expirationDate>
<priceId>CNNIC-REG-1Y</priceId>
<price>1.0</price>
<autoRenew>false</autoRenew>
<template>
<templateId>1000</templateId>
<name>xxxxxx</name>
<registrant>
<cnOrganization>xxxxxx</cnOrganization>
<organization>xxxxxx</organization>
<cnName>哈哈</cnName>
<name>haha</name>
<cnProvince>shandong</cnProvince>
<province>linyi</province>
<cnCity>lili</cnCity>
<city>lili</city>
<cnAddress>dddd</cnAddress>
<address>dddd</address>
<postal>333333</postal>
<email>service@wwwwww.com</email>
<phone>+86.13833138033</phone>
<fax>+86.13833200533</fax>
</registrant>
<adminSameAsRegistrant>true</adminSameAsRegistrant>
<techSameAsRegistrant>true</techSameAsRegistrant>
<billingSameAsRegistrant>true</billingSameAsRegistrant>
</template>
<statuses>
<status>clientDeleteProhibited</status>
<status>clientTransferProhibited</status>
</statuses>
<nsList>
<ns>ns1.123.com</ns>
<ns>ns2.123.com</ns>
</nsList>
</data>
</response>
[解决办法]
??
不懂,帮顶
不知楼主说的是否是这个?
idHTTP.get(URL)
[解决办法]
var idhttp:Tidhttp;
url:string;
s:string;
begin
idhttp:=tidhttp.create(true);
s:=idhttp.get(url);
.....
.......
end;
[解决办法]
添加个 idhttp 控件到 form上,加个button,加个 edit,在edit里输入url,在button的 click 事件里写
var
s : string;
begin
s := idhttp1.get(edit1.text);
// s 就是返回的请求结果,处理之
end;
代码就是简单到这个程度,不知道你评价代码完整与否的标准是什么。