Niklas Posted September 19, 2009 Share Posted September 19, 2009 Hello, I made a small piece of code that i think could help out others with a similar issue. I have about hundred servers that is sending welcome emails out themself instead of having WHMCS to do it. That was annoying since i couldn't resend old emails, so i decided to use the WHMCS API to send emails. But i quickly ran into an issue - i had to add every single server IP on the API allow list. As i couldn't find an option to disable this allow list, i had to figure something else out. I ended up with writing a small PHP script that acts as a proxy to the API, so i only would have to whitelist the IP of the webserver. Simply copy/paste the following code into whmcs/includes/localapi.php (actually localapi.php can be called anything), and then use that file instead of api.php: <?php $ch = curl_init(); $url = str_replace('/'.basename(__FILE__),'/api.php',$_SERVER['REQUEST_URI']); if (isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']=='on') { curl_setopt($ch, CURLOPT_URL, 'https://'.$_SERVER['HTTP_HOST'].$url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } else { curl_setopt($ch, CURLOPT_URL, 'http://'.$_SERVER['HTTP_HOST'].$url); } if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Lighttpd doesn't support the Expect header. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_exec($ch); ?> Best regards, Niklas 0 Quote Link to comment Share on other sites More sharing options...
mfoland Posted January 11, 2019 Share Posted January 11, 2019 Not to bump an old post, but I've got this to work, however, I'm wanting to upgrade a product, and I am getting Service ID Not found, when the service exists in the system. 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.