请问怎么实现PHP短信接口代理转发?
实现功能:用户原接口URL如下:
http://api.alisms.cn/tx/index.php?uid=企业ID&pwd=密码&mobile=号码&content=内容
提取上面接口中的uid(企业ID)、pwd(密码)、mobile(号码)、content(内容)等参数值转发至新接口
新接口URL:
http://sms.alisms.cn/sms.aspx?action=send&userid=企业ID&password=密码&mobile=号码&content=内容&rt=json
<?php
//提交短信
$post_data = array();
$post_data['userid'] = ;
$post_data['password'] = 'test';
$post_data['content'] = '你好test';
$post_data['mobile'] = '';
$url='http://sms.alisms.cn/sms.aspx?action=send';
$o='';
foreach ($post_data as $k=>$v)
{
$o.="$k=".urlencode($v).'&';
}
$post_data=substr($o,0,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //直接返回到变量里
$result = curl_exec($ch);
?>
请各位帮忙写下代码。