$host = 'url'
$ch = curl_init()
curl_setopt($ch, CURLOPT_URL, $host)
// 返回结果
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1)
curl_setopt($ch, CURLOPT_HEADER, 0)
// 使用POST提交
curl_setopt($ch, CURLOPT_POST, 1)
// POST参数
$str = array('a=1','b=2','c=3')
curl_setopt($ch, CURLOPT_POSTFIELDS, $str)
// 结果
$res = curl_exec($ch)
curl_close($ch)
接口文档上没有提供例子吗?给你一个例子.
=========
<?php
$client = "agent123456"
$password = "123456"
$enc ="E"
$dn = "onsalesoftware.com"
$checksum=MD5("GetProductKey".$client.$password.$dn.$enc)
$w_URL = "http://api.xinnet.com/domain/api.gb?method=GetProductKey&charset=utf-8"//定义api接口的url
$w_Parameters = "&enc=E&client=agent123456&name=onsalesoftware.com&keyname=Password&checksum=".$checksum
$curl = curl_init()//定义curl
curl_setopt($curl, CURLOPT_URL, $w_URL)
curl_setopt($curl, CURLOPT_POST, 1)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1)//设置返回结果不直接显示
curl_setopt($curl, CURLOPT_POSTFIELDS, $w_Parameters)
$data = curl_exec($curl)
curl_close($curl)
echo $data
?>
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)