Fabio92 Posted February 27, 2013 Share Posted February 27, 2013 Hi, this is my first post. But i really can't manage to solve this problem. The api system has always worked well. But yesterday stopped working. I'm using the default script: <?php $url = "http://www.domain.com/includes/api.php"; # URL to WHMCS API file $username = "xxxxx"; # Admin username goes here $password = "xxxxx"; # Admin password goes here $postfields = array(); $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "addinvoicepayment"; #action performed by the [[API:Functions]] $postfields["invoiceid"] = "1"; $postfields["transid"] = "TEST"; $postfields["gateway"] = "mailin"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } if ($results["result"]=="success") { # Result was OK! } else { # An error occured echo "The following error occured: ".$results["message"]; } ?> The problem is that the api gives no answer. I get this notices: Notice: Undefined offset: 1 in /home/admin/domains/domain.com/public_html/api_test.php on line 29 Notice: Undefined index: result in /home/admin/domains/domain.com/public_html/api_test.php on line 32 Notice: Undefined index: message in /home/admin/domains/domain.com/public_html/api_test.php on line 36 And only "The following error occured:" as result. Nothing else. What do you think can happened? I have beed struggling for hours with no result.... Thank you so much. 0 Quote Link to comment Share on other sites More sharing options...
gohigher Posted February 27, 2013 Share Posted February 27, 2013 Try adding this line: $info = curl_getinfo(); in between the lines that read: $data = curl_exec($ch); curl_close($ch); So it looks like: $data = curl_exec($ch); $info = curl_getinfo(); curl_close($ch); Then after the 'error occurred' output put this line in: echo '<pre>'.print_r($info,1); and see if you get an http response code. If you are getting a code of '0' then your firewall may be blocking your curl script and you need to whitelist your own IP address. Other codes would be helpful too... 403, 404 etc and should point you in the right direction. 0 Quote Link to comment Share on other sites More sharing options...
Fabio92 Posted February 27, 2013 Author Share Posted February 27, 2013 Here's the output. http code 200 looks like the request is ok, anyway no answer. Array ( => http://www.domain.com/includes/api.php [content_type] => text/html; charset=utf-8 [http_code] => 200 [header_size] => 403 [request_size] => 202 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.034327 [namelookup_time] => 0.000861 [connect_time] => 0.000911 [pretransfer_time] => 0.000986 [size_upload] => 693 [size_download] => 0 [speed_download] => 0 [speed_upload] => 20188 [download_content_length] => 0 [upload_content_length] => 693 [starttransfer_time] => 0.001366 [redirect_time] => 0 [certinfo] => Array ( ) [primary_ip] => xxx.xxx.xxx.xxx [primary_port] => 80 [local_ip] => xxx.xxx.xxx.xxx [local_port] => 43715 [redirect_url] => ) 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.