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

Import csv file in laravel

Remove css or js version wordpress

Mysql Subquery