showing results for - "convert curl response to json format and echo the data"
Eleonora
06 Nov 2017
1$url="https://.../api.php?action=getThreads&hash=123fajwersa&node_id=4&order_by=post_date&order=‌​desc&limit=1&grab_content&content_limit=1";
2
3//Using cURL
4//  Initiate curl
5$ch = curl_init();
6// Will return the response, if false it print the response
7curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
8// Set the url
9curl_setopt($ch, CURLOPT_URL,$url);
10// Execute
11$result=curl_exec($ch);
12// Closing
13curl_close($ch);
14
15// Will dump a beauty json :3
16var_dump(json_decode($result, true));
17//-------------------------------------------
18//using file_get_contents
19$result = file_get_contents($url);
20// Will dump a beauty json :3
21var_dump(json_decode($result, true));
22