PHP Curl Format

 try {

            $url = "http://checkip.amazonaws.com";

            $ch = curl_init();

            $headers = array(

                'Accept: application/json',

                'Content-Type: application/json',

            );

            curl_setopt($ch, CURLOPT_URL, $url);

            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

            curl_setopt($ch, CURLOPT_HEADER, 0);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            $result = curl_exec($ch);

            $res = json_decode($result,true);           

            $ipaddress = $result;

           }

           catch(Exception $e) {

            $ipaddress = 'Exception Message: ' .$e->getMessage();  

           }

Comments

Popular posts from this blog

Add Css And Js Files on Specific Page In laravel

Be 10x 10 tools from sessions

Diffrence between Put and Patch