Secure SSL / HTTPS API call with PHP

In reference to this previous question:
Connect through HTTPS instead of HTTP

Would this be the good way to make a secure API call with HTTPS?

public function demo(){
    $Username = 'username';
    $Password = 'xxxxxxxxx';
    $url = 'http://api.text-connect.co.uk/api/api.php?Username='.$Username.'&Password='.$Password.'&Action=checkcredits';


    $ch = curl_init($url);

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);


    $result = curl_exec($ch);
    curl_close($ch);

    echo $result;
}

Should i use https instead of http at the $url variable?

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories