Skip to main content
Solved

Problem with recieving data with cURL

  • June 21, 2020
  • 1 reply
  • 0 views

Hello,

I’m studying Airtable API and I have problem with receiving anything with cURL in PHP. All I’m getting is NULL value. Here is my code:

			function refreshCache(){
				//get cURL resource
				$ch = curl_init();
				
				//set url
				curl_setopt($ch, CURLOPT_URL, 'https://airtable.com/tbl5g83TtrSE0LpS0/viwcGbSmDc5FhHrHg/rec2UUOz1aQEPsuFL?api_key=MY_HIDDEN_KEY');
				$out = curl_exec($ch);
				curl_close($ch);
				file_put_contents('cache.txt', $out);
				print_r($out);
				echo("<br/>");
				var_dump(json_decode($out));
			}
			
			refreshCache();

I know that I should receive SOMETHING, because table and rows aren’t empty. What I’m doing wornd? Thank you!

Best answer by Artur_Niemiec

OK I get what’s wrong. I’ve tested it on local server with XAMPP and, when I used curl_error($ch), I get error like

error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none

Then I knew, that I should use host server, because xampp had certificate problems and I didn;t had time to solve it. How I recieved some real data with json format. And from now I think I can manage it :slightly_smiling_face:

View original
Did this topic help you find an answer to your question?

1 reply

  • Author
  • New Participant
  • 1 reply
  • Answer
  • June 21, 2020

OK I get what’s wrong. I’ve tested it on local server with XAMPP and, when I used curl_error($ch), I get error like

error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none

Then I knew, that I should use host server, because xampp had certificate problems and I didn;t had time to solve it. How I recieved some real data with json format. And from now I think I can manage it :slightly_smiling_face:


Reply