browgreg Posted April 6, 2021 Share Posted April 6, 2021 Hello, I have been trying many different ways to complete this and I am totally stuck. I can use the cURL in my terminal fine and it does what I want it to do. I am creating a system where I want the people offering the position to have an automatic system in place. this code works when I add my information, curl -H'Authorization: cpanel username:U7HMR63FHY282DQZ4H5BIH16JLYSO01M' 'https://example.com:2083/execute/Email/add_pop?email=newuser&password=12345luggage' The problem I seem to be having is that it is not connecting to the cPanel? Is this because I am on a shared hosting plan? If not then what are the parameters I need to add to the new CPANEL() I have tried username, api token and both I.P and Domain names. $cpanel = new CPANEL(); // Connect to cPanel - only do this once. // Create the user@example.com email address. $new_email = $cpanel->uapi( 'Email', 'add_pop', array( 'email' => 'user', 'password' => '12345luggage', 'quota' => '0', 'domain' => 'example.com', 'skip_update_db' => '1', ) ); What am I doing wrong apart from something obvious, I have managed to get everything working how I want in this site apart from this part. Thank you in advance, Greg Quote Link to comment https://forums.phpfreaks.com/topic/312426-using-api-token-in-php/ Share on other sites More sharing options...
requinix Posted April 6, 2021 Share Posted April 6, 2021 Unless someone here has specific knowledge about the sort of thing you're trying to do, we're not going to be able to tell you what's wrong unless you can describe what you're seeing. First thing to do is get more information. If you can't tell whether you can connect or not, that sounds like a good place to start. Maybe try some other, simpler cPanel operation to prove that the code is valid? Also see if you can get any logging or error messages that could indicate what's going wrong. 1 Quote Link to comment https://forums.phpfreaks.com/topic/312426-using-api-token-in-php/#findComment-1585608 Share on other sites More sharing options...
browgreg Posted April 6, 2021 Author Share Posted April 6, 2021 Thanks I never explained it well at all., The second lot of code is what is confusing the issue. OK, I have built a Document system where people are signed up via the club I am building this website for. The person who runs the admin of the association wants to have certain emails for different areas. That to me is not a problem, as it is a simple process via the cPanel. What I am basically asking is the terminal or command the only option to run this cURL command or can I replicate it using PHP. When I use the code suggested by cPanel it clearly is built for a different type of cPanel. When I test the code i get What I am asking is what is the best option? curl -H'Authorization: cpanel example:U7HMR63FHY282DQZ4H5BIH16JLYSO01M' 'https://example.com:2083/execute/Email/add_pop?email=newuser&password=12345luggage' Quote Link to comment https://forums.phpfreaks.com/topic/312426-using-api-token-in-php/#findComment-1585610 Share on other sites More sharing options...
maxxd Posted April 6, 2021 Share Posted April 6, 2021 So CPANEL is a dependency package that you've not included in your script. I don't use cPanel so I'm not sure how it's set up, but there should be a require or include directive in the script somewhere - either it'll include the script directly, or it'll include an autoloader file in which case you'll see a use statement naming the CPANEL class. 1 Quote Link to comment https://forums.phpfreaks.com/topic/312426-using-api-token-in-php/#findComment-1585612 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.