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 = ''.$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);

    echo $result;

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

Leave a Reply


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