Jump to content

Daniel Pointon

Member
  • Posts

    1
  • Joined

  • Last visited

About Daniel Pointon

Daniel Pointon's Achievements

Junior Member

Junior Member (1/3)

0

Reputation

  1. 0down votefavorite I'm having issues running WHMCS on a local server(AMPPS). I keep getting error 60s on the admin page when I am able to access it, despite having added a certificate(cacert.pem from https://curl.haxx.se/docs/caextract.html) to the same folder as the php.ini folder with AMPPS and setting up as the certificate(this worked for a while but something else seems to be the issue). Secondly ,I'm attempting to use WHMCS in order to make a CURL request to an API that uses OAuth. I cannot get the access token with the code(yes I have tried multiple codes) I am attempting to use, and keep getting blank responses, with response times of -1, and yet I get a blank response. Curiously the SSL verification status is 1, despite the certificate issue. Both of these issues have never affected me on another machine and no one else on the internet have had them simultaneously, they seem to be indicative of a larger issue. The CURL request is to a specific API(freeagent), using a helper class in which no one else has reported the issue, and other cURL requests have been successful using my server. Here's the code for the call(I'm using type 'oauth'): private function call($endpoint, $type, $data=array()){ $ch = curl_init(); // Setup curl options $curl_options = array( CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_USERAGENT => 'Depot-PHP' ); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/../cacert.pem"); $splitBody = false; // Set curl url to call if ($type == 'oauth'){ $curlURL = $this->oauthAccessTokenURL; } else { $curlURL = $this->apiUrl.$endpoint; $curl_options += array( CURLOPT_HTTPHEADER => array( 'Authorization: Bearer '.$this->accessToken, 'Accept: application/json', 'Content-Type: application/json', ), CURLOPT_HEADER => 1 ); $splitBody = true; } // type of request determines our headers switch($type){ case 'post': $curl_options = $curl_options + array( CURLOPT_POST => 1, CURLOPT_POSTFIELDS => json_encode($data) ); break; case 'put': $curl_options = $curl_options + array( CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => json_encode($data) ); break; case 'delete': $curl_options = $curl_options + array( CURLOPT_CUSTOMREQUEST => 'DELETE', CURLOPT_POSTFIELDS => $data ); break; case 'get': $curlURL .= '?&'.http_build_query($data); $curl_options = $curl_options + array( ); break; case 'oauth': $curl_options = $curl_options + array( CURLOPT_USERPWD => $this->clientId.':'.$this->clientSecret, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $data ); break; } // add url $curl_options = $curl_options + array( CURLOPT_URL => $curlURL ); // Set curl options curl_setopt_array($ch, $curl_options); // Send the request $this->result = curl_exec($ch); // freeagent returns location: for some responses if ($splitBody){ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($this->result, 0, $header_size); $this->result = substr($this->result, $header_size); $this->headers = $this->parseHeaders($header); } // curl info $this->info = curl_getinfo($ch); if ($this->debug){ var_dump($this->result); var_dump($this->info); } // Close the connection curl_close($ch); return json_decode($this->result); } } The whole function returns blank, and the information for the CURL request is as follows: { [ "url" ] => string(51) "https://api.sandbox.freeagent.com/v2/token_endpoint" [ "content_type" ] => NULL [ "http_code" ] => int(0) [ "header_size" ] => int(0) [ "request_size" ] => int(0) [ "filetime" ] => int(-1) [ "ssl_verify_result" ] => int(1) [ "redirect_count" ] => int(0) [ "total_time" ] => float(0.05031) [ "namelookup_time" ] => float(0.029338) [ "connect_time" ] => float(0.050294) [ "pretransfer_time" ] => float(0) [ "size_upload" ] => float(0) [ "size_download" ] => float(0) [ "speed_download" ] => float(0) [ "speed_upload" ] => float(0) [ "download_content_length" ] => float(-1) [ "upload_content_length" ] => float(-1) [ "starttransfer_time" ] => float(0) [ "redirect_time" ] => float(0) [ "redirect_url" ] => string(0) "" There seems to be some form of underlying issue here, but it's unclear what it is? Any help would be appreciated
  2. Welcome to WHMCS.Community Daniel Pointon! We're glad you're here please take some time to familiarise yourself with the Community Rules & Guidelines and take a moment to introduce yourself to other WHMCS.Community members in the Introduce Yourself Board.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated