First use CURL to connect with another service.
That way, for example:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link_para_chamar);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '10');
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
// Habilita cache do DNS (remover o // para habilitar):
//curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, true);
//curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, '3600');
// Habilita verificação de SSL (em caso de problema defina ambos para FALSE, não é recomendado desligar!):
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
$resposta = curl_exec($ch);
$erroSite = curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200 ? true : false;
$erroCurl = curl_error($ch);
curl_close($ch);
So to define the $link_para_chamar
, utilize json_encode
:
$json = [];
$json['login'] = '[email protected]';
$json['senha'] = 'senha';
$json['campanha'] = 'ID 1234';
$json['mensagens'][1]['numero'] = '2799999999';
$json['mensagens'][1]['msg'] = 'MENSAGEM';
$json['mensagens'][1]['data'] = '2016-08-11 09:20:00';
$link_para_chamar = 'https://site.com/apiJSON.php?data='.json_encode($json);
What is the problem you are having to use it?
– stderr
It’s just that I have no idea how to call her "spin" you know. If you paste this link with the correct parameters in the address bar and press enter it sends msg. The problem is that I don’t know how to run the link through PHP.
– Thiago
A redirect wouldn’t work for your problem? http://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php
– Vagner Araujo