Reputation: 49384
I have a couple of links that I need to execute by code:
Here's what it looks like:
http://rest.nexmo.com/sms/xml?api_key=mykey&api_secret=mysec&from=me&to=somenumber&text=test1
I need to do some kind of look which will do it by code:
For example:
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
Is this at all possible using php or php/javascript?
Upvotes: 0
Views: 93
Reputation: 307
<?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);
?>
use CURL For execute your Link $sub_req_url = "http://rest.nexmo.com/sms/xml?api_key=mykey&api_secret=mysec&from=me&to=somenumber&text=test1 "
Upvotes: 3