bin 15 und hab demletzt erst mit PHP angefangen und möchte gerne mit Hilfe der XML Daten von steamcommunity.com dynamische Signaturen erstellen. Dazu brauche ich eine Variable in der URL: http://steamcommunity.com/id/$steamname/?xml=1. Leider funktioniert das so nicht (Whitescreen wenn echo $steamname->steamID). Gibt es da irgendeine Möglichkeit, dort eine Variable einzubauen?
Wen's interessiert - der Code:
getxml.php
PHP-Code:
<?php
$getxml = simplexml_load_file('http://steamcommunity.com/id/empyyy/?xml=1');
?>
PHP-Code:
<?php
// include
require('getxml.php');
// set vars
$name = $getxml->steamID;
$onlinestate = $getxml->onlineState;
$gamestate = $getxml->inGameInfo->gameName;
$thumb = $getxml->avatarIcon;
// create images
$background = imagecreatefrompng('bg.png'); // 244*48
$avatar = imagecreatefromjpeg($thumb);
if($onlinestate == in-game)
{
$border = imagecreatefrompng('green.png');
}
if($onlinestate == online)
{
$border = imagecreatefrompng('blue.png');
}
if($onlinestate == offline)
{
$border = imagecreatefrompng('gray.png');
}
// allocate colors
$transparency = imagecolorallocatealpha($background, 0, 0, 0, 127);
$lblue = imagecolorallocate($background, 92, 180, 242);
$lgreen = imagecolorallocate($background, 167, 236, 77);
// merge images
imagecopymerge($background, $border, 4, 4, 0, 0, 40, 40, 100);
imagecopymerge($background, $avatar, 8, 8, 0, 0, 32, 32, 100);
// text
imagettftext($background, 9, 0, 50, 13, $lblue, 'ARIALBD.TTF', $name);
imagettftext($background, 9, 0, 50, 27, $lblue, 'ARIAL.TTF', $onlinestate);
imagettftext($background, 9, 0, 50, 40, $lblue, 'ARIAL.TTF', $gamestate);
// output image and free memory
header('Content-Type: image/png');
imagepng($background);
imagedestroy($background);
imagedestroy($avatar);
imagedestroy($border);
?>

Grüße
PS: Suche wollte ich eigentlich nutzen, aber "simplexml_load_file" ist anscheinend zu allgemein

Einen Kommentar schreiben: