Jump to content

List Products Through The API?


dhollingworth

Recommended Posts

Hi

 

I'd like to be able to list products and prices on our main website (I.e. outside of WMCS) and I was looking for some API functions that would allow me to do this. However there don't appear to be any product related functions in the API documentation (other than getting products for a specific client).

 

Is it possible to access the products through the API?

 

Thanks

 

David

Link to comment
Share on other sites

There is a "getproducts" api command, but it is not documented.

 

It probably doesnt take any parameters.

 

EDIT: yup. it works fine with no parameters (postfields)

 


<?php
$url = "https://url.to.whmcs.tld/includes/api.php"; # URL to WHMCS API file
$username = "apiuser"; # Admin username goes here
$password = "apipass"; # Admin password goes here

$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["action"] = "getproducts"; #action performed by the API:Functions

$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, $postfields);
$data = curl_exec($ch);
curl_close($ch);

print $data;
?>

Edited by laszlof
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.

Guest
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