am not good enough with curl functions but I understand some :P
I have this webservice http://www.psnapi.com.ar/ps3/api/psn.asmx?op=getGames
that required to enter a variable "sPSNID" to get list of games
the XML output will be like this:
<ArrayOfGame>
<Game>
<Id>NPWR00132_00</Id>
<IdGameEurope/>
<Title>GTA IV</Title>
<Image>http://trophy01.np.community.playstation.net/trophy/np/NPWR00132_00_FB41DD6DD0A782A55D7A8497108B84EB19EDA56C/EF4A80E7CECAFBA06A2F60DA0CC3CAC53B77C9D0.PNG</Image>
<Progress>3</Progress>
<TrophiesCount>
<Earned>3</Earned>
<Total>3</Total>
<Platinum>0</Platinum>
<Gold>0</Gold>
<Silver>0</Silver>
<Bronze>3</Bronze>
</TrophiesCount>
<Trophies/>
<OrderPlayed>1</OrderPlayed>
<Updated>false</Updated>
<LastUpdated>2012-12-09T13:24:24</LastUpdated>
<Released>0001-01-01T00:00:00</Released>
<TotalPoints>1275</TotalPoints>
<TotalTrophies>66</TotalTrophies>
<UserPoints>45</UserPoints>
<Stars>3.975</Stars>
<Reviews>20</Reviews>
<Platform>ps3</Platform>
</Game> ...... and so on until </ArrayOfGame>
am using this class
<?php
class GetGamespsn{
public $psnid;
public $xmlobj;
public function __construct($psnid='') {
if($psnid) {
$this->psnid = $psnid;
$this->load();
}
}
public function load() {
if($this->psnid) {
$url = "http://www.psnapi.com.ar/ps3/api/psn.asmx/getGames?sPSNID={$this->psnid}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$this->xmlobj = simplexml_load_string($result);
}
}
public function __get($name) {
return $this->xmlobj->Game->$name;
}
}
$psnid = new GetGamespsn("hawkiq");
print $psnid->Title; // Just for testing to get title
?>
but allways I got this error
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Start tag expected, '<' not found in C:\AppServ\www\lab\getgames.php on line 25
Warning: simplexml_load_string() [function.simplexml-load-string]: System.NullReferenceException: Object reference not set to an instance of an obj in C:\AppServ\www\lab\getgames.php on line 25
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in C:\AppServ\www\lab\getgames.php on line 25