Moin liebe Community,
ich sitze schon etwas an diesem Problem und komme nicht weiter, bin aber auch Neuling auf diesem Gebiet.
Mein Quellcode:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.openligadb.de/api/getmatchdata/bl1/2016");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$matches = json_decode($output, true);
echo "<table width='20%' border='0'>";
foreach ($matches as $match) {
$bild1 = $match['Team1']['TeamIconUrl'];
$bild2 = $match['Team2']['TeamIconUrl'];
//echo "<tr><td>".$match['MatchDateTime']."</td>";
echo "<td id='football'>".$match["Team1"]["TeamName"]."</td>";
echo "<td id='football'>".$match["Team2"]["TeamName"]."</td>";
echo "<td id='football'>".$match["MatchResults"]["MatchResult"]["PointsTeam1"]."</td>"; <--Hier müsste das Problem sein!!
echo "<td id='football'>".$match["MatchResults"]["MatchResult"]["PointsTeam2"]."</td>"; <---Hier
// echo "<td id='football'>".$match["Match"]["MatchResults"]["MatchResult"[t[value='MatchResult']]/following-sibling::*[1]/t/value]."</td>";
echo "<td><img src =$bild1></td>";
echo "<td><img src =$bild2></td>";
echo "</tr>";
}
Das ist die API:
<Match>
<Goals>...</Goals>
<Group>...</Group>
<LastUpdateDateTime>2016-09-19T23:10:36.1</LastUpdateDateTime>
<LeagueId>3005</LeagueId>
<LeagueName>1. Fußball-Bundesliga 2016/2017</LeagueName>
<Location>
<LocationCity>München</LocationCity>
<LocationID>34</LocationID>
<LocationStadium>Allianz Arena</LocationStadium>
</Location>
<MatchDateTime>2016-08-26T20:30:00</MatchDateTime>
<MatchDateTimeUTC>2016-08-26T18:30:00Z</MatchDateTimeUTC>
<MatchID>39648</MatchID>
<MatchIsFinished>true</MatchIsFinished>
<MatchResults>
<MatchResult>
<PointsTeam1>6</PointsTeam1> <----Das möchte ich abrufen!!
<PointsTeam2>0</PointsTeam2> <----Das auch!
<ResultDescription>Ergebnis nach Spielende</ResultDescription>
<ResultID>67922</ResultID>
<ResultName>Endergebnis</ResultName>
<ResultOrderID>2</ResultOrderID>
<ResultTypeID>2</ResultTypeID>
</MatchResult>
<MatchResult>
<PointsTeam1>2</PointsTeam1>
<PointsTeam2>0</PointsTeam2>
<ResultDescription>Ergebnis zur Halbzeit</ResultDescription>
<ResultID>67923</ResultID>
<ResultName>Halbzeitergebnis</ResultName>
<ResultOrderID>1</ResultOrderID>
<ResultTypeID>1</ResultTypeID>
</MatchResult>
</MatchResults>
<NumberOfViewers>75000</NumberOfViewers>
<Team1>
<ShortName>FC Bayern</ShortName>
<TeamIconUrl>
https://upload.wikimedia.org/wikiped...Cnchen.svg.png
</TeamIconUrl>
<TeamId>40</TeamId>
<TeamName>Bayern München</TeamName>
</Team1>
<Team2>
<ShortName/>
<TeamIconUrl>
https://upload.wikimedia.org/wikiped...n-Logo.svg.png
</TeamIconUrl>
<TeamId>134</TeamId>
<TeamName>Werder Bremen</TeamName>
</Team2>
<TimeZoneID>W. Europe Standard Time</TimeZoneID>
</Match>
Ich möchte nun das Endergebnis abrufen..nur bekomme ich immer eine Fehlermeldung wen ich es abrufe wie das andere auch!
ICh denke es liegt daran das hier "MatchResult" zwei mal auftaucht, aber wie sag ich ihm das er nur den ersten Wert abrufen soll?
Vielen Dank für eure Hilfe
Danke
NoHand
ich sitze schon etwas an diesem Problem und komme nicht weiter, bin aber auch Neuling auf diesem Gebiet.
Mein Quellcode:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.openligadb.de/api/getmatchdata/bl1/2016");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$matches = json_decode($output, true);
echo "<table width='20%' border='0'>";
foreach ($matches as $match) {
$bild1 = $match['Team1']['TeamIconUrl'];
$bild2 = $match['Team2']['TeamIconUrl'];
//echo "<tr><td>".$match['MatchDateTime']."</td>";
echo "<td id='football'>".$match["Team1"]["TeamName"]."</td>";
echo "<td id='football'>".$match["Team2"]["TeamName"]."</td>";
echo "<td id='football'>".$match["MatchResults"]["MatchResult"]["PointsTeam1"]."</td>"; <--Hier müsste das Problem sein!!
echo "<td id='football'>".$match["MatchResults"]["MatchResult"]["PointsTeam2"]."</td>"; <---Hier
// echo "<td id='football'>".$match["Match"]["MatchResults"]["MatchResult"[t[value='MatchResult']]/following-sibling::*[1]/t/value]."</td>";
echo "<td><img src =$bild1></td>";
echo "<td><img src =$bild2></td>";
echo "</tr>";
}
Das ist die API:
<Match>
<Goals>...</Goals>
<Group>...</Group>
<LastUpdateDateTime>2016-09-19T23:10:36.1</LastUpdateDateTime>
<LeagueId>3005</LeagueId>
<LeagueName>1. Fußball-Bundesliga 2016/2017</LeagueName>
<Location>
<LocationCity>München</LocationCity>
<LocationID>34</LocationID>
<LocationStadium>Allianz Arena</LocationStadium>
</Location>
<MatchDateTime>2016-08-26T20:30:00</MatchDateTime>
<MatchDateTimeUTC>2016-08-26T18:30:00Z</MatchDateTimeUTC>
<MatchID>39648</MatchID>
<MatchIsFinished>true</MatchIsFinished>
<MatchResults>
<MatchResult>
<PointsTeam1>6</PointsTeam1> <----Das möchte ich abrufen!!
<PointsTeam2>0</PointsTeam2> <----Das auch!
<ResultDescription>Ergebnis nach Spielende</ResultDescription>
<ResultID>67922</ResultID>
<ResultName>Endergebnis</ResultName>
<ResultOrderID>2</ResultOrderID>
<ResultTypeID>2</ResultTypeID>
</MatchResult>
<MatchResult>
<PointsTeam1>2</PointsTeam1>
<PointsTeam2>0</PointsTeam2>
<ResultDescription>Ergebnis zur Halbzeit</ResultDescription>
<ResultID>67923</ResultID>
<ResultName>Halbzeitergebnis</ResultName>
<ResultOrderID>1</ResultOrderID>
<ResultTypeID>1</ResultTypeID>
</MatchResult>
</MatchResults>
<NumberOfViewers>75000</NumberOfViewers>
<Team1>
<ShortName>FC Bayern</ShortName>
<TeamIconUrl>
https://upload.wikimedia.org/wikiped...Cnchen.svg.png
</TeamIconUrl>
<TeamId>40</TeamId>
<TeamName>Bayern München</TeamName>
</Team1>
<Team2>
<ShortName/>
<TeamIconUrl>
https://upload.wikimedia.org/wikiped...n-Logo.svg.png
</TeamIconUrl>
<TeamId>134</TeamId>
<TeamName>Werder Bremen</TeamName>
</Team2>
<TimeZoneID>W. Europe Standard Time</TimeZoneID>
</Match>
Ich möchte nun das Endergebnis abrufen..nur bekomme ich immer eine Fehlermeldung wen ich es abrufe wie das andere auch!
ICh denke es liegt daran das hier "MatchResult" zwei mal auftaucht, aber wie sag ich ihm das er nur den ersten Wert abrufen soll?
Vielen Dank für eure Hilfe
Danke
NoHand
Comment