php curl示列

$username = 13800138000;
02
$password = 123456;
03
$sendto = 13912345678;
04
$message = "测试一个试试看!";
05
 
06
$curlPost = 'username='.urlencode($username).'&
07
password='.urlencode($password).'&
08
sendto='.urlencode($sendto).'&
09
message='.urlencode($message).'';
10
 
11
$ch = curl_init();//初始化curl
12
curl_setopt($ch,CURLOPT_URL,'http://sms.api.bz/fetion.php');//抓取指定网页
13
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
14
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
15
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
16
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
17
$data = curl_exec($ch);//运行curl
18
curl_close($ch);
19
print_r($data);//输出结果

你可能感兴趣的:(PHP)