2013-05-20 28 views
0

即時通訊嘗試從我的cpanel通過API獲取xml提要。我已經嘗試了幾種方法(見下文)來通過授權來獲取xml提要。Flex HttpService授權獲取xml Feed

在我的瀏覽器,我可以通過以下方式獲得飼料:

http://user:[email protected]:2086/xml-api/listaccts? 

來自服務器的飼料例如:

<listaccts> 
<acct> 
<disklimit>2500M</disklimit> 
<diskused>56M</diskused> 
<domain>domain.com</domain> 
<email>[email protected]</email> 
<ip>xx.xx.xx.xx</ip> 
<max_defer_fail_percentage>unlimited</max_defer_fail_percentage> 
<max_email_per_hour>unlimited</max_email_per_hour> 
<maxaddons>*unknown*</maxaddons> 
<maxftp>5</maxftp> 
<maxlst>*unknown*</maxlst> 
<maxparked>*unknown*</maxparked> 
<maxpop>25</maxpop> 
<maxsql>1</maxsql> 
<maxsub>5</maxsub> 
<min_defer_fail_to_trigger_protection>5</min_defer_fail_to_trigger_protection> 
<owner>root</owner> 
<partition>home</partition> 
<plan>Basic</plan> 
<shell>/usr/local/cpanel/bin/noshell</shell> 
<startdate>13 Feb 17 07:05</startdate> 
<suspended>0</suspended> 
<suspendreason>not suspended</suspendreason> 
<suspendtime/> 
<theme>x3</theme> 
<unix_startdate>1361109935</unix_startdate> 
<user>xxxxxxxx</user> 
</acct> 
</listaccts> 

我的應用程序腳本:

<s:HTTPService id="clientList" method="GET" resultFormat="e4x"/> 

在腳本:

[Bindable] 
private var clientInfo:Object = new Object(); 

private function clients(event:Event):void{ 

      clientList.url = 'http://' +loginUsername.text 
      clientList.url += ':' + loginPassword.text 
      clientList.url += '@' + loginServer.text; 
      clientList.url += ':2086/xml-api/listaccts?'; 

      clientList.addEventListener("result", clientResult); 
      clientList.addEventListener("fault", clientFault); 
      clientList.send(); 

      CursorManager.setBusyCursor(); 

     } 

     public function clientResult(event:ResultEvent):void { 


      clientInfo = clientList.lastResult.acct; 
      CursorManager.removeBusyCursor(); 

     } 

     public function clientFault(event:FaultEvent):void { 

      var faultstring:String = event.fault.faultString; 
      Alert.show("Unable to obtain client list","Error"); 

      CursorManager.removeBusyCursor(); 
     } 

我做錯了什麼,我不斷收到錯誤(無法獲取客戶端列表),我想我可以嘗試我使用的身份驗證方式。

回答

0

不要連接字符串以添加您的用戶名和密碼。

稱之爲WebService並使用setCredentials。

+0

你也許有我可以看看的樣本?不是Flex編程的專業人員。 – user1705839