Created
May 24, 2013 09:59
-
-
Save John-Henrique/5642517 to your computer and use it in GitHub Desktop.
Exemplo de como enviar SMS utilizando POST em PHP no SMSdeck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Envio de SMS através do método POST. | |
* | |
* @author John-Henrique | |
* @copyright 2013 | |
* @version 1.0 | |
* @link http://smsdeck.com.br/documentacao/enviar-sms-post.html | |
* | |
*/ | |
// dados do SMS | |
$array = array(); | |
$array['numero_destino'] = "550011112222"; | |
$array['numero_origem'] = "550011112222"; | |
$array['mensagem'] = "sua mensagem 160 digitos"; | |
$array['agendar'] = ""; // este SMS será enviado imediatamente | |
$array['token'] = "a54d54ae7r84gfg1fh4g78h1mj4k7u"; | |
$array['chave'] = "8qw4er8w4sdfg21hd2jf65u6uk8k9j89"; | |
// A ação que para enviar SMS | |
$acao = "sms"; | |
// cria uma conexão CURL | |
$curl = curl_init( "http://smsdeck.com.br/api/". $acao ); | |
// define que o envio deve ser via POST | |
curl_setopt($curl, CURLOPT_POST, 1); | |
// define o conteúdo da mensagem | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $array ); | |
// ignora cabeçalhos | |
curl_setopt($curl, CURLOPT_HEADER, 0); | |
// retorna o resultado como texto | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
// saida do conteudo na variavel $resultado | |
$resposta = curl_exec($curl); | |
// fecha a conexão CURL | |
curl_close($curl); | |
// exibe na tela o retorno do servidor | |
print_r( $resposta, true ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment