I can not use CURL on the Godaddy server - php

Needing information about the goDaddy server error, I used CURL with the following commands in PHP.
I already tested it on another hosting server and it returned me successfully.
I'm using an API for sending messages in whatsapp, everything works: locally and on another server, except on goDaddy.
$endpoint = "https://site...";
$curl = curl_init($endpoint);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER , true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $dados);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true);
$executa_api= curl_exec($curl);
curl_close($curl);
$retorno= json_decode($executa_api);
do I need to authenticate something to use third-party API in godaddy?
My phpinfo():

Related

Azure DevOps API gives anonymous access error when creating a work item

I have been working on a project to create Azure DevOps work items from a form on a WordPress page. Everything works on my local WordPress installation running on WAMPserver but as soon as it is moved to the development or production servers I get the following error "TF400813: Resource not available for anonymous access. Client authentication required." I am fairly certain that this will be something that needs to be handled on the server but I am not sure what. I was able to due full authentication with the service account that was created for this purpose on my WAMPserver installation but the Windows Server IIS installation is not cooperating. The WordPress page handles authenication and passing data with CURL via PHP. Here is the code.
$url = 'https://organiztion-url/UMCom_DefaultCollection/area_path/_apis/wit/workitems/$'.$_POST['IssueType'].'?api-version=5.0';
$headers = array('Content-Type: application/json-patch+json');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, 'account:password');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');//PATCH
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
$resultStatus = curl_getinfo($curl);
The solution was to use both a PAT and standard authentication as our local environments could not use the PAT correctly and our Dev, Stage, and Prod environments require the PAT.

PHP POST not working, what module to enable

I want to make a PHP POST request from my new VPS server to another IP address. I checked the firewall and everything seemed fine but the request never went to the other IP, so I then tried making the same request with node.js and it went through. The question is, what PHP module/extension do I need to enable to allow php requests with or without curl.
A simple CURL request:
$ch = curl_init();
$url='http://example.com/';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);

How to add Virtual host IP and Domain in PHP Curl?

Hi There I have added a virtual host in my windows Host file like this.
192.192.192.192 www.domain.com
I made some php curl request and it is working fine on my local but when I try on my live domain. There I don't understand where to add Virtual host. It is Windows Server. I know there is something in PHP curl. Anyone help how to send host IP and domain in PHP curl. Here is my working code on local machine.
$crul = curl_init();
curl_setopt($crul, CURLOPT_HEADER, false);
curl_setopt($crul, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($crul, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crul, CURLOPT_URL, 'http://www.domain.com'); // where ruquest send
curl_setopt($crul, CURLOPT_POST, true);
curl_setopt($crul, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($crul, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($crul);

php curl is not working over https

I am trying to fetch data from rest api(https) using curl. I have downloaded cacert.pem from http://curl.haxx.se/docs/caextract.html and moved into project root directory. Here is my code but it's not working. Can anyone help me?
$curl = curl_init();
// Set some options
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($curl, CURLOPT_CAINFO, __DIR__.DIRECTORY_SEPARATOR.'cacert.pem');
curl_setopt($curl, CURLOPT_URL, 'https://startupgenome.com/api/2/boulder-co');
// Send the request & save response to $resp
$resp = curl_exec($curl);
curl_close($curl);
print_r($resp);
There are some problems. If you open your API url https://startupgenome.co/api/2/boulder-co you can see that the certificate is not valid. If you accept them you get an 404 (Well this doesn't seem right.).
So i think you should first insert the correct URL.
The second is. If the certificate is not valid on the server side you can't verify the host and your cacert.pem make no sense if the destination has no valid certificate.
If you really want to access that page then disable the checks but don't forget to enable that on production mode.
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

PHP CURL not sending as POST

I have the following simple code:
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('name' => 'michael'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
When I tried this on a different windows 7 xampp computer, it sends as POST just fine. But then I went to another windows 7 xampp computer and it sends it as GET. Same exact code on the API and the post. I check the method on the API and it says its coming in as GET, but it's fine on the other computer. Both are running windows 7 and xamp. Cannot figure what is going on. I tried with out any POSTFIELDS too and with a normal string, didn't help. Thanks

Categories