0

I am beginning a foray into PHP and curl, and I encountered a bit of a snag. I am using curl to make a request to an API, but it doesn't seem to do anything. The request I am trying to make is a POST request with basic auth, that I expect should return an access token. It does not seem to return anything. I'm still fairly new to curl/php, so I'm assuming I just made a silly error somewhere

Thanks in advance!

function Fire($agent, $secret, $url) {
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
            curl_setopt($curl, CURLOPT_USERPWD, $agent . ":" . $secret);
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $result = curl_exec($curl);
            curl_close($curl);
            echo $result;
            return $result;
        } 
Hailrig
  • 15
  • 5
  • First of all, use `var_dump` to make debug outputs, rather than `echo`. If the value is `false` for example, with echo you don’t get anything you can _see_. Secondly, there are methods to find out what _error_ curl might have encountered, so go and make use of those. – CBroe Jun 08 '20 at 11:12
  • @CBroe Ah, good point. It does indeed return false. curl_error returns "certificate problem: unable to get local issuer certificate" – Hailrig Jun 08 '20 at 11:44

1 Answers1

0

After it was mentioned that there is a function to get the error message for Curl I was able to track the issue down and solve it via curl: (60) SSL certificate problem: unable to get local issuer certificate

Hailrig
  • 15
  • 5