Skip navigation links

MySQL Forums :: PHP :: processing http xml return in php


Advanced Search

processing http xml return in php
Posted by: Angela Smith ()
Date: October 02, 2013 10:02AM

I am a newbie in PHP. I am making a call to an http api using wget (the hosting site doesn't offer http_get). The call returns an xml set when do it manually. But it appears that my wget call is putting the response into an array.
I am unable to access the array and not sure where to go from here.
Below is my code. FYI -- The first 4 elements of the xml play_by_play object are: id, visitor, home, status.

<?php
exec('wget http://api.sportsdatallc.org/mlb-t3/pbp/99a0f209-2c69-49a4-99f9-8aebdf55b6e9.xml?api_key=API_KEY', $array);

//print_r(array_values($array));
echo $array["play_by_play"][0]->id;


?>

I have tried another approach and have confirmed that I am getting a response (count = 1). That is below. But I can't get to the content.

<?php
$myResult=exec('wget http://api.sportsdatallc.org/mlb-t3/pbp/99a0f209-2c69-49a4-99f9-8aebdf55b6e9.xml?api_key=API_KEY', $array);

print count($myResult);
print $myResult;
$arrElem="";
if (count($myResult) > 0)
{
for ($i=0;$i<count($myResult);$i++) {
$arrElem=ltrim(rtrim($myResult));
echo $arrElem;
?>

Thanks,

Angie

Options: ReplyQuote


Subject Written By Posted
processing http xml return in php Angela Smith 10/02/2013 10:02AM
Re: processing http xml return in php Peter Brawley 10/02/2013 10:50AM
Re: processing http xml return in php Angela Smith 10/02/2013 11:04AM
Re: processing http xml return in php Peter Brawley 10/05/2013 11:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.