Jump to content

Creating an invoice from a custom module during a DailyCronJob event


Recommended Posts

We're trying to create invoices during a DailyCronJob event hook, from a custom module we implemented. So we try to use the WHMCS API (/includes/api.php) but we get an error 404 from the Curl response. The page show


result=error;message=Invalid IP xxx.xxx.xxx.xxx;


when accessed directly from the browser, and this is fine, but when accessed from within the server, we get an error 404. This is what we use to make the Curl request


$url = "http://domain.com/includes/api.php";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $arrayData);
$data = curl_exec($ch);


By the way, this is taken directly from the documentation page. What could be the problem? Is this the proper way of creating invoices from within a cron job?

Link to comment
Share on other sites

Have you whitelisted the IP under Setup > General Settings > Security tab?


Yes, I did put the IP in the whitelist seetting.


The problem was, actually, the Apache settings; After looking at the logs, I realized that, when doing an HTTP request from "", the server tried to find the resource in "/var/www/html/" when our installation of WHMCS is in "/var/whmcs".


The problem was actually a virtual host settings, and simply change the default document root to the virtual host's.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • 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