Voila jai fai laquisition dune API d'envoie de sms (sur smsfactor.com) et dans leir documentation ils me donne un code php incomprehensible pour moi???? et jessaye de le relier a un formulaire html qui utilisera ce code php en tant que action,
Merci pour votre aide. (Di dessous le.code fourni)
[Code] <?php
$token = "your.token"; // https://secure.smsfactor.com/token.html;
$content = "Test API";
$numbers = array('0601020304','0704030201');
$sender = "PHP";
$recipients = array();
foreach ($numbers as $n) {
$recipients[] = array('value' => $n);
}
$postdata = array(
'sms' => array(
'message' => array(
'text' => $content,
'sender' => $sender
),
'recipients' => array('gsm' => $recipients)
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.smsfactor.com/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Authorization: Bearer ' . $token));
$response = curl_exec($ch);
curl_close($ch); [code]
Merci pour votre aide. (Di dessous le.code fourni)
[Code] <?php
$token = "your.token"; // https://secure.smsfactor.com/token.html;
$content = "Test API";
$numbers = array('0601020304','0704030201');
$sender = "PHP";
$recipients = array();
foreach ($numbers as $n) {
$recipients[] = array('value' => $n);
}
$postdata = array(
'sms' => array(
'message' => array(
'text' => $content,
'sender' => $sender
),
'recipients' => array('gsm' => $recipients)
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.smsfactor.com/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Authorization: Bearer ' . $token));
$response = curl_exec($ch);
curl_close($ch); [code]