How do I get json answer in php? [duplicate]

0

I have the link:

https://dominio.com/apiJSON.php?data={"login":"[email protected]","senha":"Minhasenha","campanha":"ID 1234","mensagens":{"1":{"numero":2799999999,"msg":"Uma mensagem qualquer","data":"2015-10-19 01:07:52"}}}

By pasting this link in the browser with the correct parameters I get the following response in the browser:

{"tip":1,"msg":[{"numero":2799999999,"id":"1234","status":1}]}

I want to get this answer and work it with php or javascrpit, whatever. But I need to get this information. Can someone help me? Thanks!

    
asked by anonymous 18.05.2016 / 15:16

2 answers

2

Live,

$data = file_get_contents('www.meusite.com');
$data = json_decode($data,true); 

From here it's like you have a normal array ..

Probably in your case you will have to use: link

file_get_contents('dominio.com/apiJSON.php?data='.urlencode(';{"login":"e‌​[email protected]","senha":"Minhasenha","campanha":"ID 1234","mensagens":{"1":{"numero":2799999999,"msg":"Uma mensagem qualquer","data":"2015-10-19 01:07:52"}}}')) 

Because you have special characters .. (you can always send this data by post instead of query string)

Any questions please;)

    
18.05.2016 / 15:31
0

$ data = file_get_contents ('www.mysite.com'); $ data = json_decode ($ data);

Try this: P

    
18.05.2016 / 16:42