我需要通过代码执行一些链接:
这是它的样子:
http://rest.nexmo.com/sms/xml?api_key=mykey&api_secret=mysec&from=me&to=somenumber&text=test1
我需要做一些通过代码来做的事情:
例如:
Start loop:
execute:
http://rest.nexmo.com/sms/xml?api_key=mykey&api_secret=mysec&from=me&to=somenumber&text=test1
execute:
http://rest.nexmo.com/sms/xml?api_key=mykey&api_secret=mysec&from=me&to=somenumber&text=test1
end loop
这是否可以使用php或php / javascript?
答案 0 :(得分:3)
<?php
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
?>
使用CURL执行链接 $ sub_req_url =“http://rest.nexmo.com/sms/xml?api_key=mykey&api_secret=mysec&from=me&to=somenumber&text=test1 “