Monday, July 17, 2023

On localhost, cURL requests are successful, but not on web servers.

Problem: 

1. Curl request not working on live server

2. cURL GET request working on localhost, but no on web server

3. On localhost, cURL requests are successful, but not on web servers.

4. API working in localhost but not working while uploading in server

5. API functioning locally but not when uploading to a server


Solution: just add this on your php code! Or enable SSL on your server.

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);















curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://sandbox.mywebsite.io/distributor/secondary-invoice/create',
  CURLOPT_SSL_VERIFYPEER => false, // Add to avoid error on web deployment
  CURLOPT_SSL_VERIFYHOST => false, // Add to avoid error on web deployment
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  /* CURLOPT_POSTFIELDS =>  json_encode($postData_Invoice_headers), */
  CURLOPT_POSTFIELDS =>  $postData_Invoice_headers,
  CURLOPT_HTTPHEADER => $post_headers_api,
));

Saturday, July 15, 2023

EMS update distributor info for beatroute API


EMS update distributor info for beatroute API
EMS update distributor info TIN (tax identification number)

tags

Friend Connect