Re: fatal error when trying to use structmem();
"barnbroker" <[email protected]> Fri, 13 Oct 2006 12:52:02 -0000
| Newsgroups | gmane.text.xml.rpc.specification |
|---|---|
| Message-ID | <[email protected]> |
Thanks for the help... this seemed to work. Youre right. It was returning an array. Now I have another question. I am trying this same thing with another API. However this API is not returning an array. It looks like it is returning a long string of xml. When I do a: var_dump($myList); I get this when I view the source: string(1484) "<?xml version="1.0" encoding="utf-8"?> <params> <param> <value> <struct> <member> <name>video_title</name> <value> <string>Speakers</string> </value> </member> <member> <name>video_keyword</name> <value> <string>Speakers</string> </value> </member> </struct> </value> </param> </params> " So when I do: $vidTitle = $myList['video_title']; //this doesnt return anything $Host = $vidTitle->scalarval(); //this gives me a fatal error Im getting the fatal error.... How would I get the value of "video_title"..? Thanks for your help..... --- In [email protected], "I Wayan Yuliarta" <netstinger@...> wrote: > > Hi there barnbroker... > > The return value from xmlrpc_decode is a PHP value, usually is an > array value or a scalar value. > > From the code, the $myList value is an associative array not an object. > > Change the following codes : > > $vidTitle = $myList->structmem('Host'); > $Host = $vidTitle->scalarval(); > echo $Host; > > To : > > $Host = $myList['Host']; > echo $Host; > > > > Good Luck, > > > Wayan > > > > --- In [email protected], "barnbroker" <rob.bowers@> wrote: > > > > Here's my php code: > > > > <?php > > require_once('xmlrpc/xmlrpc.inc'); > > $xmlrpc_msg = new xmlrpcmsg('examples.getallheaders'); > > $vidClient = new > > xmlrpc_client('/server.php','phpxmlrpc.sourceforge.net',80); > > $resp = $vidClient->send($xmlrpc_msg); > > if (!$resp->faultCode()) { > > $myList = xmlrpc_decode($resp->value()); > > $vidTitle = $myList->structmem('Host'); > > $Host = $vidTitle->scalarval(); > > echo $Host; > > } else { > > printf($resp->faultCode()); > > } > > ?> > > > > When I try to run this I get a fatal error: > > > > Fatal error: Call to a member function on a non-object in > > /home/virtual/site303/fst/var/www/html/rpc_test.php on line 8 > > > > Line 8 is: > > > > $vidTitle = $myList->structmem('Host'); > > > > > > > > Any ideas why this might be happening? > > > Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/xml-rpc/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/xml-rpc/join (Yahoo! ID required) <*> To change settings via email: mailto:[email protected] mailto:[email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/