0

我正在使用 osticket api 并开发了此功能以将 osticket 集成到我的 Web 应用程序中:

    function ReadTicket($ticketID)
    {
     $osticket = new SoapClient('url');

    $args = array(

        'username'        => 'someuser',

        'password'        => 'some pass',

        'ticketID'        => 1234); 

    try {
        $result = $osticket->__call('ostTicket.getMessages',$args);



      print_r( $result  );    





}

catch (SoapFault $e) {

    throw $e;

} 
} 

这是 print_r 命令的结果:

Array ( [0] => stdClass Object ( [question] => stdClass Object ( [id] => 80 [created] => 2012-11-25T14:48:29-06:00 [name] => name [message] => body ) [answers] => Array ( [0] => stdClass Object ( [id] => 80 [created] => 2012-11-30T23:52:48-06:00 [name] => Admin Admin [message] => testttttttttt ) ) ))

如何访问结果并仅打印出 id 和 message?

这是对肥皂电话 http://www.cyberde.nl/software-en-US/osticket-soap-mod/ostticket-getmessages/的参考

4

2 回答 2

0
foreach($result[0]['answer'] as $ans)//one ore more answers
 echo $ans['id']." '".$ans['message']."'<br/>";
于 2012-12-01T12:43:42.280 回答
0

它应该像$result[0]->question->id或对于多个结果

foreach($result as $r){
  echo $r->question->id;
  foreach($r->answers as $answer){
    echo $answer->id;
  }
}
于 2012-12-01T13:02:26.387 回答