Need help understanding basics of XML-API for PHP

marcelg

Member
Nov 8, 2007
5
0
51
Hello,

I have spent lots of time with this and think it's time to ask for some advice.

I have downloaded the xmlapi.php file and have it included in my scrpt.

My script specifies the server IP and authenticates via the $xmlapi->hash_auth fine.

I am just trying to run one command to list accounts: print $xmlapi->listaccts();

This gives me a blank screen and when I "View Source" I see lots of blank lines. If I comment out the print $xmlapi->listaccts() the blank lines don't appear in the source.

I checked my error_log with $xmlapi->set_debug(1) and found lots of data going in there.

error_log shows my Authorization Header followed by any entry starting with RESPONSE: \n <listaccts>\n and it goes on to output all the information I'm trying to get.

How do I access this information and have it display on my HTML page instead of the error log? I'm guessing I'm missing something here. Please give me some advice.
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
listaccts(), which calls xmlapi_query() internally, returns a data structure (unless you specify 'json' in a prior invocation of set_output())

PHP data structures, like arrays and objects, should not be provided as an argument to the print directive. If you know that you have an array, you can use print_r(). If you're want to get an idea of what a variable is or what it contains, you're better served by using var_dump() to simply dump the variable; var_dump() will provide additional markup so that you can understand the internal structure and value of the variable's contents.

-DavidN