Skip to main content

cURL example or template for UAPI Return Email Accounts

Comments

16 comments

  • ankeshanand
    You need it in PHP cURL or Terminal one?
    0
  • Indinfer
    I need to operate remotely. I think that if the curl line would work from a Windows command line, it should also work invoked from my program in Lisp and C++. So I guess I need terminal mode cURL. I'm okay trying something that works on a Mac, Linux, or Unix command line, because it might also work from Windows. If we are getting all the email accounts one by one, I don't think I need a working loop. What I think I would need is something like 1. How to get the first account. 2. How to get the next account. 3. How to know when I got all the accounts. Of course, I don't know whether cPanel UAPI works this 1, 2, 3 way.
    0
  • ankeshanand
    0
  • Indinfer
    A appreciate your patience in trying to help me with my problem. Yes, a link is good. I could not find "cURL" in the link I showed and the link you showed. I have a test website to figure out how to do this. I can reveal the website and the token because I will delete the token to prevent some third party from abusing the website. The website is:
    0
  • ankeshanand
    Thats for Creating Email Accounts.... and what you did is actually wrong... The reference I gave is for whmapi1 which is on Port 2087. The basic usage would be like: https://hostname.example.com:2087/cpsess##########/json-api/accountsummary?api.version=1&user=username
    In Your Case, it would be like curl https://hostname.example.com:2087/cpsess##########/json-api/list_pops_for?api.version=1&user=username
    Before that, You have to authenticate the root user using create_user_session ... which will give you a Security Token cpsess... The Response on My Server is: {"metadata":{"command":"list_pops_for","version":1,"reason":"OK","result":1},"data":{"pops":["webmaster@host.cloudmate.in">}}
    If you need more Help, just let me know!
    0
  • Indinfer
    Before that, You have to authenticate the root user using create_user_session ...

    I think you figured out where my problem is because you alerted me that I need to get a proper session token. Seems to me that THAT's what I don't know how to do. I was thinking that I could not use anything from whmapi1 because I (and hopefully my future clients) will be using a website hosting service, such as GoDaddy.com. We will not be providing any website hosting. We will be using. Am I wrong here? Can I indeed use both whmapi1 and uapi? My eyes seem to be missing documentation on exactly how to use an API token to get a session token (cpsess...). I'm trying looking in both cPanel UAPI and WHM API1. Either my eyes keep missing it or I'm not looking in the right place. Could you point me to documentation that will hopefully make very clear to me how to use cURL to use an API token to get a session token?
    0
  • ankeshanand
    I think you figured out where my problem is because you alerted me that I need to get a proper session token. Seems to me that THAT's what I don't know how to do. I was thinking that I could not use anything from whmapi1 because I (and hopefully my future clients) will be using a website hosting service, such as GoDaddy.com. We will not be providing any website hosting. We will be using. Am I wrong here? Can I indeed use both whmapi1 and uapi? My eyes seem to be missing documentation on exactly how to use an API token to get a session token (cpsess...). I'm trying looking in both cPanel UAPI and WHM API1. Either my eyes keep missing it or I'm not looking in the right place. Could you point me to documentation that will hopefully make very clear to me how to use cURL to use an API token to get a session token?

    To Create or List or do anything regarding API, You need whmapi1 and for that, You have to have a root account or Reseller Account. Because Client Side API is also available in cPanel but for that you'll need API keys for each cpanel account which seems impossible. From what you mentioned, I think you are preparing for an Email Hosting Solution or maybe some part of it. For Email Hosting, You can do the following: 1.Setup a Small VPS with about 2 Cores and a Lot of Storage and Get cPanel. You can Host Emails from there using SMTP and IMAP/POP3 2. Use PHP for Making Client Area. It supports cURL and a Lots of other things needed to make Cross Connection. You can then integrate a Third party Webmail Service and all others through whmapi1 and Provide your end users also with API for email solutions. ['url'>; echo $login_url; } curl_close($curl);
    Although this is the backend of what I made on PHP for Root login. Although, You can also use Root password instead of API token for Authentication... If you need it for Terminal, let me know and I'll type it for you...
    0
  • Indinfer
    I have not said much about what I am trying to do. So, therefore, although I think what you are saying about getting will work, I don't think it will work for me. So, I will say a little more about what I am trying to do. My applications will be desktop, Android, and iPad. It is for the masses of people who want multiple email accounts. Most will be very unsophisticated users. And they don't want to become sophisticated. They want to click on a button, and one of their email accounts disappears. Type in a user name and click on another button and a new email account appears ready for use. The few sophisticated users should find my app enables them to create and delete their email addresses super-fast. All of these users will not want to spend any significant money to rent a VPS. Instead, they will want their own personal domain name and the cheapest kind of website for their email. But now, I think I got a little further. But I still need help. I finally found this page:
    I got the three errors. Does this only bear out what you described, that every user needs to get a VPS server? Or is there some way to figure out what I need to do from these errors? Error 1 (could not resolve hose). I thought the host was "assigned-email-manager.com". Why does it mention cpanel? Error 2 (port number). I thought the port number ended in a 3 (as in 2083). Where is the 'F'? Error 3 (protocol). I thought cURL did support HTTPS. Is it enabled? Maybe not. How would I enable HTTPS in cURL? Who knows? Maybe if we can solve just one of the errors, all of the errors will go away, and the cURL command will work.
    0
  • ankeshanand
    As Said, Your App then needs API Token Created by respective users... C:\Users\Abc>curl 'https://assigned-email-manager.com:2083/execute/Email/list_pops' -H "Authorization: cpanel username:7FBI3QIC1HNXYORBCDRWU2XL6TZP09N7"
    This will work!
    0
  • Indinfer
    Yes, your cURL line works much better. You smashed two of the bugs. I scrutinized your line. It looks like you used double quotes instead of single quotes for the -H parameter. And you put a space between the -H switch and the parameter part. When I did that, I found that both of these versions worked better than before. curl 'https://assigned-email-manager.com:2083/execute/Email/list_pops' -H "Authorization: cpanel username:7FBI3QIC1HNXYORBCDRWU2XL6TZP09N7" curl -H "Authorization: cpanel username:7FBI3QIC1HNXYORBCDRWU2XL6TZP09N7" 'https://assigned-email-manager.com:2083/execute/Email/list_pops'
    I think your order makes more sense. So, I am happy to continue with the cURL line as you presented it. Maybe you get different results than I because you are executing from the server, and I am executing remotely? Here is my session now: C:\Users\rlewi>curl 'https://assigned-email-manager.com:2083/execute/Email/list_pops' -H "Authorization: cpanel username:7FBI3QIC1HNXYORBCDRWU2XL6TZP09N7" curl: (1) Protocol "'https" not supported or disabled in libcurl
    Maybe there is a cURL parameter I can add that force-enables HTTPS? I will look at the output from curl --help
    0
  • Indinfer
    Curious, using https versus http: C:\Users\rlewi>curl 'https://assigned-email-manager.com:2083/execute/Email/list_pops' -H "Authorization: cpanel username:7FBI3QIC1HNXYORBCDRWU2XL6TZP09N7" curl: (1) Protocol "'https" not supported or disabled in libcurl C:\Users\rlewi>curl 'http://assigned-email-manager.com:2083/execute/Email/list_pops' -H "Authorization: cpanel username:7FBI3QIC1HNXYORBCDRWU2XL6TZP09N7" curl: (1) Protocol "'http" not supported or disabled in libcurl
    I don't know where anything is enabled or disabled in libcurl. I presume cURL uses libcurl? But I can deal with enabling a protocol if enabling amounts to including some command line parameter. I don't even know where cURL is located in Windows. Windows 10 comes with cURL already installed.
    0
  • Indinfer
    To Create or List or do anything regarding API, You need whmapi1, and for that, You have to have a root account or Reseller Account. Because Client-Side API is also available in cPanel but for that you'll need API keys for each cpanel account which seems impossible. From what you mentioned, I think you are preparing for an Email Hosting Solution or maybe some part of it. For Email Hosting, You can do the following: 1.Setup a Small VPS with about 2 Cores and a Lot of Storage and Get cPanel. You can Host Emails from there using SMTP and IMAP/POP3 2. Use PHP for Making Client Area. It supports cURL and a Lots of other things needed to make Cross Connection. You can then integrate a Third party Webmail Service and all others through whmapi1 and Provide your end users also with API for email solutions.

    . It is very possible you gave me THE answer early on.
    0
  • ankeshanand
    . It is very possible you gave me THE answer early on.

    Access Denied.... That dosen't seem likely. Have you checked the API tokens? If you still not able to do it... Could you share the API Details in Conversation? (Remember, cPanel Advises not to share personal data on Forums... and the same will be said by cPRex after he views this message! ;) ) Make a Plan like this: 1 Purchase a Cheap VPS from Hetzner or Contabo or someone like that....(They charge like 5$/Month) 2. Setup WHM/cPanel 3 Use json-api on Port 2087 if you want to achieve Email Hosting.
    0
  • cPRex Jurassic Moderator
    Great collaboration here!
    0
  • Indinfer
    Ankesh Anand, Yes, I did check the tokens. I think remote access to cPanel is prohibited by the web hosting provider for shared website hosting. I did not verify this because I did not want to wait over 90 minutes to connect via their chat. I think we have the cURL line correct. I greatly appreciate your help. I am shopping web hosting. You have given me a good idea of what to expect.
    0

Please sign in to leave a comment.