epicconstruct Posted November 30, 2009 Share Posted November 30, 2009 I accessed the API for 'getclientdata' and was able to get it to run successfully. However some of the fields returned their contents wrapped in <![CDATA[ {$data} ]]> . Particularly firstname, lastname, companyname, and lastlogin. All of the other data returned as regular text. Does anybody know why it returns this way? Or a decent way of handling the oddly returned data? Overall, it seems the API documentation is somewhat lacking. I'm actually planning on writing a class I can use to hit the API instead of pasting their long API example in every piece of code I'd like to make a call. Has anybody done this already or have any more information on the API? Thanks 0 Quote Link to comment Share on other sites More sharing options...
epicconstruct Posted November 30, 2009 Author Share Posted November 30, 2009 I altered the example code. It seems to have fixed the problem. I'm still curious though if anybody has any comments on the original post. $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $temp[1] = str_replace('<![CDATA[', '', $temp[1]); $temp[1] = str_replace(']]>', '', $temp[1]); $results[$temp[0]] = $temp[1]); } 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted November 30, 2009 Share Posted November 30, 2009 <![CDATA embedded textvalues are protected from interpreting into a wrong markup. just preg match the result: $clientarr = whmcsapiGetClientsDatabyID('1'); // custom function test with client ID "1" above echo "<pre>clientarr"; print_r($clientarr); echo "</pre>"; preg_match('%^\<\!\[CDATA\[(.*)\]\]\>$%',$clientarr['lastlogin'],$match); echo "<pre>match"; print_r($match); echo "</pre>"; $lastlogin = $match[1]; 0 Quote Link to comment 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.