opened
joxley
username_0
I am having the same no response problem as issue #5 but I am using https and not using 2Fa.
I am get no output.
==============================================
include "include/cpaneluapi.class.php"; //include the class file
// credentials
include_once('include/cpanel_inc.php');
// connect cpanel api
$capi = new cpanelAPI( $account, $passwd, $ip, $secret ); // instantiate the object
//no SSL
// $capi->port = 2082;  //Check this!
// $capi->ssl = FALSE;
//get response
$response = $capi->uapi->Mysql->get_restrictions(); 
print_r($capi->getLastRequest());
==========================================
If I uncomment the 2 lines that disable SSL I get the following output, "http://xxxxxxxxxxxxx:2082/execute/Mysql/get_restrictions?"
When logging in manually I use, https://xxxxxxxxxxxx:2083.
Also no response
issue
created
joxley
username_0
Are you sending the "security token"?
When testing manually I needed the "security token" to get it to work.
https://xxxxxxxxxx.com:2083/cpsessxxxxxxx/execute/Mysql/get_restrictions
comment
created
N1ghteyes
username_1
@username_0 this might be a case of debugging in the wrong way?

A couple of questions:
- I assume you want to connect over SSL? If so, there's no need to specify the port unless its non-standard
- What are you expecting to see when you use the getLastRequest() method? The current output looks correct for it, as it returns the URL used for the last request, not the result of it.

Try this:

```php
include_once('include/cpanel_inc.php');
$capi = new cpanelAPI( $account, $passwd, $ip); //No need for the secret unless you're using 2FA
$response = $capi->uapi->Mysql->get_restrictions();
print_r($response);
php```

Is that blank?

Also, could you confirm if you have access to WHM as well, or just cPanel?
comment
created
joxley
username_0
My goal is to list, add and delete Email Forwarders.
I was doing it on the my shared hosting cPanel account with xmlapi.php.
After upgrading to an VPS server using https, xmlapi.php stopped working.
I have access to WHM and cPanel.
I found that UAPI is the lastest cpanel api and the one I should be using.
===============================
include "include/cpaneluapi.class.php";
include_once('include/cpanel_inc.php');
$capi = new cpanelAPI( $account, $passwd, $ip );
$response = $capi->uapi->Mysql->get_restrictions();
echo '<pre>', print_r($response), '</pre>';
===================================
Blank!
comment
created
N1ghteyes
username_1
Ok, next questions:
 - Do you get anything in the php error logs?
 - Did you pull the code from Github, download the latest as a zip or download one of the 'releases'?

What does the following return (if anything):
```php
include_once('include/cpanel_inc.php');
$capi = new cpanelAPI( $account, $passwd, $ip); //No need for the secret unless you're using 2FA
$response = $capi->uapi->Mysql->get_restrictions();
print_r($capi->getError());
```
comment
created
joxley
username_0
I did not check any php error log. Which error log could I check?
I downloaded zip file from Github.
print_r($capi->getError()); displayed nothing.
comment
created
N1ghteyes
username_1
@username_0 The error log location depends on your hosting setup, there are a few places you can try:

- In the folder you've uploaded your code to, there maybe an error.log file.
- The default log file location for cPanel is /home/{cpanel user name}/logs/

you might also be able to view the error log entries from the cPanel dashboard for the account as well. They can normally be found by navigating to Errors (Under Metrix).

If you can find the log, please paste a few of the latest errors here.
comment
created
joxley
username_0
13-Mar-2018 23:05:20 UTC] PHP Warning:  include_once(): Failed opening 'includes/cpanel_inc.php' for inclusion (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home/xxxxxxxxxx/public_html/websites_v4_test/test_uapi.php on line 7

This is the last error I have and I know it is working now because I displayed the data from the cpanel_inc.php after including it.

No new errors in the last hour or so.
Still only a blank page after call.
comment
created
joxley
username_0
I don't know if this will help you:
I added print statements at the top and bottom of my test script.
When I run the script without "$response = $capi->uapi->Mysql->get_restrictions();" I get both print statements.
When I run the script with "$response = $capi->uapi->Mysql->get_restrictions();"  I get the top print statement but not the bottom print statement.
comment
created
N1ghteyes
username_1
@username_0 It sounds like something in your environment is causing php to throw a Fatal error. It could be something as simple as an old version of PHP thats the issue.

What version of PHP are you running?
comment
created
joxley
username_0
I have only been on this VPS for less then a month.
Running PHP v5.6.
Could there be something not enabled in the PHP?
comment
created
N1ghteyes
username_1
@username_0 PHP 5.6 is fine.

its very possible that Curl isn't enabled, at that's required and not always enabled by default.

A quick test is to add a php file with the following, and navigate to it in your browser:

```php
print "file opened <br />";
$ch = curl_init();
print "curl opened";
```

if you don't see "curl opened", printed to screen then the curl_init() will be throwing a fatal error. If that's the case, you'll need to install and enable php-curl, or ask your hosting providers to do it for you.

Its definitely worth looking into effective debugging in general as it will make spotting config issues and other problems much easier :).
comment
created
joxley
username_0
"curl opened" displayed ok.

Here is my curl settings in php.ini:
================================
cURL support | enabled
-- | --
cURL Information | 7.53.1
Age | 3
Features
AsynchDNS | No
CharConv | No
Debug | No
GSS-Negotiate | No
IDN | No
IPv6 | Yes
krb4 | No
Largefile | Yes
libz | Yes
NTLM | Yes
NTLMWB | Yes
SPNEGO | Yes
SSL | Yes
SSPI | No
TLS-SRP | No
Protocols | dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host | x86_64-redhat-linux-gnu
SSL Version | OpenSSL/1.0.1e
ZLib Version | 1.2.3
libSSH Version | libssh2/1.4.2
=======================================
comment
created
barartm
username_2
Hello, im hacing the same problem, just not response, i already tried on two servers with same result, just a “NULL” text, my code:

include "cpclass.php"; 
$cPanel =  new cpanelAPI('mysuer', 'mypass', 'server.domain.com'); 
$response = $cPanel->uapi->DomainInfo->list_domains();
var_dump($response);

Using uapi or api2 makes no difference
comment
created
N1ghteyes
username_1
@username_0 @username_2 Ok, I'll spin up a few test boxes to see if i can reproduce this. I'm fairly sure its an environment issue, but hopefully i can at least narrow the cause down.

@username_2 Can you confirm what version of PHP you're using, if you have Curl installed and whether its a private server or shared one?

Thanks
comment
created
joxley
username_0
Thanks for your help.
I am using PHP version 5.6 and have Curl installed.
Is there anything in the php.ini that is needed that would cause it not to work?
comment
created
joxley
username_0
No errors, just not returning.
This is a new VPS server and I did find some PHP extension I had to add and/or enable.
comment
created
barartm
username_2
Hello @username_1 , thanks for your reply and help

Im using php 7.0, i can confirm that curl is installed and enabled, its a private server, there are no errors when open file and no errors/warnings on server log :/
comment
created
joxley
username_0
I got it working.
I had cpanel support look at my server and they found the problem.

I have another question for you.
What is the format your class based on cPanels examples?
$delete_forwarder = $cpanel->uapi(
    'Email', 'delete_forwarder',
    array(
        'address'        => 'user@example.com',
        'forwarder'      => 'fwdtome@example.com',
         )
);
comment
created
barartm
username_2
And what was the problem and solution? -.- dont keep it only for you
comment
created
joxley
username_0
I have a new VPS server using cPanel. To update Apache or php.ini you use EasyApache 4 but it never worked. I contacted cPanel support and they fixed it. Now EasyApache 4 works and cPanel uapi is working. :)
comment
created
barartm
username_2
@username_0 I do not have problems with EA4 (it works fine in all my servers) so i do no think this was the problem however... your problem was on the server you want to run the phpclass or the server you want to connect?
comment
created
joxley
username_0
My problem was on my new VPS server. I also have a shared hosting server that I have been using api 2 for about 4 years. It took the cPanel support teem 3 tries to fix the VPS server cPanel but the phpclass is working ok now.
comment
created
barartm
username_2
Yes, i understand that is your new vps, but how you use it? You use the phpclass on it to conect to an account on another server? Or you use the phpclass from another server/account to connect to this?
comment
created
joxley
username_0
I use the phpclass to add and delete email forwarders from my websites. I find it easier to setup my website members with a email forwarder then to give each member an email account.
comment
created
barartm
username_2
it seems that you dont get my question.... lets try again...

How do You use the phpclass?

a) do you use it on your new vps to conect to an account on another server?
b) do you use it on another server/account to connect to an account your new vps?
c) do you use it on your new vps to connect to a local account on the same new vps?
comment
closed
N1ghteyes
username_1
issue
created
N1ghteyes
username_1
@username_2 that would certainly do it, 2083 should be open by default. Ah well, good catch.

I'll find some time to update the docs to include notes on both these issues.

Thanks
comment