John Davidson

php - how to fix wordpress get curl on online website

0 comments
Message:


on local the code working fine, but on online website


this fakejson working file
https://jsonplaceholder.typicode.com/todos
but


<?php
$response = wp_remote_get( 'https://client.medobay.com/facet/popularPackages/11-10-2020' );
var_dump($response);


output:


"cURL error 6: Could not resolve host: client.medobay.com"



My Answer:
If the code is working fine on your local machine but not on your online website, it could be due to server configuration issues or restrictions on the online server. Here are a few steps you can take to troubleshoot and fix the issue:

1. Check if cURL is enabled on your online server: Make sure that cURL extension is enabled on your online server. You can check this by creating a PHP file with `phpinfo()` function and checking if cURL is listed in the output.

2. Check for firewall or security restrictions: Some hosting providers may have restrictions on outgoing requests using cURL. Check with your hosting provider if there are any restrictions in place that could be blocking the requests.

3. Check for SSL certificate issues: If the website you are trying to access is using HTTPS, make sure that the SSL certificate is valid and trusted. cURL may fail to make requests to websites with invalid SSL certificates.

4. Check for any proxy settings: If your online server is behind a proxy, you may need to configure cURL to use the proxy settings. You can do this by setting the CURLOPT_PROXY option in your cURL request.

5. Check for any other server configuration issues: Make sure that the server configuration on your online website is compatible with the cURL request you are making. Check for any differences in PHP versions, server settings, or other configurations that could be causing the issue.

If you have tried the above steps and are still facing issues, you may need to contact your hosting provider for further assistance in resolving the cURL issue on your online website.

Rate this post

5 of 5 based on 4809 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us