curl_error($ch) to know if there's any error with curl. And it let me know that I'm facing the issue because of SSL validation issue with the API URL.
So, I removed the
https in the API URL. And it worked!
I know its a security compromise! But the referrer url is using http, so I need to remove the SSL validation from api url too.