[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
Backup
/
14082024
/
Data
/
htdocs
/
htdocs
/
siakad
/
aulia
/
[
Home
]
File: curl.php
<?php function http_request($url){ // persiapkan curl $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // set user agent curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); // return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output = curl_exec($ch); // tutup curl curl_close($ch); // mengembalikan hasil curl return $output; } $url = "https://mjkn.rsaulia.com/aulia-api/emr/listUgd"; $method = "GET"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output = curl_exec($ch); // tutup curl curl_close($ch); // mengembalikan hasil curl echo $output; $pasien = http_request("https://mjkn.rsaulia.com/aulia-api/emr/listUgd"); echo "http_request=".$pasien."<br>"; //echo "file_get_contents=".file_get_contents("https://api.github.com/users/petanikode"); $profile = http_request("https://api.github.com/users/petanikode"); // ubah string JSON menjadi array $profile = json_decode($profile, TRUE); ?> <br> <!DOCTYPE html> <html> <head> <title>Curl Data JSON</title> </head> <body> <img src="<?php echo $profile['avatar_url']; ?>" width="64" /> <br> <p> Nama: <?php echo $profile["name"] ?><br> URL: <a href="<?php echo $profile["html_url"] ?>"><?php echo $profile["html_url"] ?></a><br> Lokasi: <?php echo $profile["location"] ?> </p> </body> </html>