$curl = curl_init();
curl_setopt_array($curl , [
CURLOPT_RETURNTRANSFER =>TRUE,
CURLOPT_URL => 'https://ortam.etu.edu.tr/Services/get_user_card_information/?apikey=XXXXXXXXX&username=ZZZZZZZZZZ',
]);
$response = curl_exec($curl);
$response = json_decode($response, TRUE);
var_dump($response);
I was able to get a response from a different API call, but I cannot get a response from this API, it comes back as NULL.
https://api.nasa.gov/neo/rest/v1/feed?start_date=2023-12-01&end_date=2023-12-08&api_key=XXXXXXXXXXXXXXX
This API works correctly.
2
Answers
If you making a request to API endpoint which has SSL Certificate you should set
CURLOPT_SSL_VERIFYHOST
andCURLOPT_SSL_VERIFYPEER
options tofalse
Not Recommend (Only for Development)
Recommend
The problem is solved by this certificate which is provided by the cURL creator (extracted from Mozilla): https://curl.haxx.se/ca/cacert.pem
So after downloading this cacert.pem file into your project, in PHP you can now do this:
Alternatively, this can be set globally by adding the following to your php.ini
You need to check for any errors in the cURL request using
curl_error
function which returns any error happens in the request phase:That’s means that there is an issue with the SSL certificate on the requested endpoint.
To solve this, you need to disable the SSL verification using
or to request the UN-SECURED http like:
Note the
http://ortam.
instead ofhttps://ortam.
However, this is not a good idea at all to disable the SSL verification.