Page 2 of 2

Posted: Sat Nov 26, 2005 1:47 pm
by unsuaulvb
thing is that

Code: Select all

$path = "http://gamercard.xbox.com/$name.card";
isnt a image but a html document will it still work

Posted: Sat Nov 26, 2005 1:53 pm
by foobar
unsuaulvb wrote:thing is that

Code: Select all

$path = "http://gamercard.xbox.com/$name.card";
isnt a image but a html document will it still work
Now we're talking! This is the kind of information you should have mentioned straight off the bat! :)

The short answer is: no, it won't work. If you want to print out the text in an HTML doc as an image, you will need to parse the HTML file and retrieve the relevant text from it. If you could post a link to an example XBox-Live card, I could help you out with the parsing.

Posted: Sat Nov 26, 2005 1:58 pm
by unsuaulvb

Posted: Sat Nov 26, 2005 2:34 pm
by foobar

Code: Select all

<?php

/* Open file - change path to suit your needs */
$fp = fopen('unusualvb.card', 'r');

/* Read the card file */
while ($tmp = fread($fp, 4096)) {
  $file .= $tmp;
}

/* ---Let's do the Regex dance...--- */

/* Match nick */
preg_match('@<span class="XbcFLAL">([^<]+)</span>@', $file, $matches);
$name = $matches[1];

/* Match avatar */
preg_match('@<img class="XbcgcGamertile" height="64" width="64" src="([^"]+)" />@', $file, $matches);
$avatar = $matches[1];

/* Match rep */
preg_match('@<img src="([^"]+)" />@', $file, $matches);
$rep = $matches[1];

/* Match score */
preg_match('@<span class="XbcFRAR">([\d]+)</span>@', $file, $matches);
$score = $matches[1];

/* Match zone */
preg_match('@<span class="XbcFRAR">([^<]+)</span>@', $file, $matches);
$zone = $matches[1];

/* Match game links */
preg_match_all('@<a href="(http\:\/\/live\.xbox\.com\/[\w]+-[\w]+\/profile\/Achievements\/ViewAchievementDetails\.aspx\?compareTo\=[^"]+)">@', $file, $matches);
$links = $matches[1];

/* Match game titles & icons */
preg_match_all('@<img height\="32" width\="32" title\="([^"]+)" alt\="" src="(http\:\/\/tiles\.xbox\.com\/tiles\/[\w]{2}\/[\w]{2}\/[^=]+\=\.jpg)" />@', $file, $matches);
$titles = $matches[1];
$images = $matches[2];

?>
Whew... there you go! Now put that into your GD code, and off you go! :wink:

Posted: Sat Nov 26, 2005 2:35 pm
by josh
You can find command line tools that can create 'thumnails' of webpages, it is trivial however

Posted: Sat Nov 26, 2005 2:36 pm
by unsuaulvb
thanks but one question do i have to position all that stuff one by one

so i have

Code: Select all

/* Open file - change path to suit your needs */
$fp = fopen('unusualvb.card', 'r');

/* Read the card file */
while ($tmp = fread($fp, 4096)) {
  $file .= $tmp;
}

/* ---Let's do the Regex dance...--- */

/* Match nick */
preg_match('@<span class="XbcFLAL">([^<]+)</span>@', $file, $matches);
$name = $matches[1];

/* Match avatar */
preg_match('@<img class="XbcgcGamertile" height="64" width="64" src="([^"]+)" />@', $file, $matches);
$avatar = $matches[1];

/* Match rep */
preg_match('@<img src="([^"]+)" />@', $file, $matches);
$rep = $matches[1];

/* Match score */
preg_match('@<span class="XbcFRAR">([\d]+)</span>@', $file, $matches);
$score = $matches[1];

/* Match zone */
preg_match('@<span class="XbcFRAR">([^<]+)</span>@', $file, $matches);
$zone = $matches[1];

/* Match game links */
preg_match_all('@<a href="(http\:\/\/live\.xbox\.com\/[\w]+-[\w]+\/profile\/Achievements\/ViewAchievementDetails\.aspx\?compareTo\=[^"]+)">@', $file, $matches);
$links = $matches[1];

/* Match game titles & icons */
preg_match_all('@<img height\="32" width\="32" title\="([^"]+)" alt\="" src="(http\:\/\/tiles\.xbox\.com\/tiles\/[\w]{2}\/[\w]{2}\/[^=]+\=\.jpg)" />@', $file, $matches);
$titles = $matches[1];
$images = $matches[2];
and

Code: Select all

<?php
$im = ImageCreate(204, 104);
$bg = imagecolorallocate($im, 0, 0, 0);
$fontcolor = imagecolorallocate($im, 255, 255, 522);
$path = "http://gamercard.xbox.com/$name.card"; 
if ( $_GET['gamertag'] == "" ) {
    $gamertag = "No Gamertag";
} else {
   $gamertag = $_GET['gamertag'];
}
////////////////////////////////////
$str = "$gamertag";
$name = str_replace(" ", "%20", $str);
$name = str_replace(".png", "", $name);
$name = str_replace(".jpg", "", $name);
$name = str_replace(".gif", "", $name);
////////////////////////////////////
ImageString  ($im, 0, 0, 0, "echo <iframe src= http://gamercard.xbox.com/$name.card scrolling=no frameBorder=0 height=140</iframe>", $fontcolor);
////////////////////////////////////
Header('Content-type: image/png');
imagepng($im);
ImageDestroy ($im);

?>
how do i put together do i have to like do each thing 1 by one