我是php开发的新手,我刚刚听说过curl。我有这个数据,我在表格行动中发布
<form id="new_member_sms" name="new_member_sms" method="post" action="http://myserver.com/app_api.php?view=send_sms&&user=username&&pass=password&&message=hello+this+message+is+dynamic+from+server&&sender_id=BlaySoft&&to=<?php echo $row_rs_sms['phone_no']; ?>&&key=4">
</form>
我想知道我是否可以将此帖子消息"http://myserver.com/app_api.php?view=send_sms&&user=username&&pass=password&&message=hello+this+message+is+dynamic+from+server&&sender_id=BlaySoft&&to=<?php echo $row_rs_sms['phone_no']; ?>&&key=4"
包装在php curl中并将其发送到服务器
答案 0 :(得分:2)
您案例中PHP
的curl帖子的基本版本如下:
$data = array(
'view' => 'send_sms',
'user' => 'username',
// ...
// add remaining post fields here
// ...
);
$url = 'http://myserver.com/app_api.php';
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
curl_exec($handle);
$data
数组应包含您要通过POST
答案 1 :(得分:0)
如果您想提交表单(不使用curl
),请在表单中包含所有参数作为隐藏输入:
<form id="new_member_sms" name="new_member_sms" method="post" action="http://myserver.com/app_api.php">
<input type="hidden" name="view" value="send_sms">
<input type="hidden" name="user" value="username">
<!-- and so on - put all your parameters here -->
<input type="submit" value="Submit">
</form>