[-]
Shout:
Click Refresh to load shouts.

Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PHP] get character info
11-07-2009, 04:50 PM
Post: #1
[PHP] get character info
Hey,

I was wondering how I can get a players info from tibia.com and post it on my website..?

I followed some old threads in this board but all I could manage t oget from those was a variable that said "ArrayArray" .. Confused some1 has a code i could copy and learn from or something?

thanks in advance,
Find all posts by this user
Quote this message in a reply
11-07-2009, 06:04 PM
Post: #2
RE: [PHP] get character info
(11-07-2009 04:50 PM)Khoda Wrote:  Hey,

I was wondering how I can get a players info from tibia.com and post it on my website..?

I followed some old threads in this board but all I could manage t oget from those was a variable that said "ArrayArray" .. Confused some1 has a code i could copy and learn from or something?

thanks in advance,

Search for: curl and preg_match_all.

Example:
PHP Code:
<?php
set_time_limit
(50000);

$u "http://example.com";
$ch curl_init(); 
curl_setopt($chCURLOPT_URL,$u); 
curl_setopt($chCURLOPT_RETURNTRANSFER,1);
curl_setopt($chCURLOPT_TIMEOUT3);
$result curl_exec($ch); 
curl_close($ch); 

preg_match_all('expresion'$result$sectionsPREG_SET_ORDER);

 echo 
'<pre>';
 
print_r($sections);
 echo 
'</pre>';
?>

Gathering information.
Find all posts by this user
Quote this message in a reply
11-08-2009, 10:10 AM
Post: #3
RE: [PHP] get character info
okay thanks Smile
Find all posts by this user
Quote this message in a reply
03-22-2010, 08:37 AM
Post: #4
RE: [PHP] get character info
The basic logic for the beginners through each character in the string and compare it to all possibilities creating a counter for each possible character
<?
$string='Count the character frequency of this string';

$count_chars = explode(' ', $string);
$a = $x = $z = $other = 0;
for($i = 0; $i < sizeof($count_chars); $i++)
{
switch($count_chars[$i])
{
case "a": $a++;
break;

case "x": $x++;
break;

case "z": $z++;
break;

default: $other++;
break;
}
}
print "Instances of <br>a = $a<br>x = $x<br>z = $z<br>";
?>

iedge
Find all posts by this user
Quote this message in a reply
04-11-2010, 06:55 AM
Post: #5
RE: [PHP] get character info
Well, I used to do it this way:

Code:
$site = file_get_contents("http://www.tibia.com/community/?subtopic=whoisonline&world=Aldora");
$begin = strpos($site, '?subtopic=characters&name=') + 26; //start of nick
$end = strpos($site, '">', $begin);  //end of nick

while ($begin !== false) {
    $player = substr($site, $begin, $end-$begin);
    $begin = strpos($site, '<TD WIDTH=10%>', $end) + 14;
    $end = strpos($site, '>', $begin);
    $level = intval(substr($site, $begin, $end-$begin));
    $begin = strpos($site, '<TD WIDTH=20%>', $end) + 14;
    $end = strpos($site, '</TD>', $begin);
    $voc = substr($site, $begin, $end-$begin);
    $begin = strpos($site, '?subtopic=characters&name=', $end) + 26;
    if ($begin < $end) $begin = false;
    $end = strpos($site, '">', $begin);
}

I am basically searching for charcter right in front of nick, level or vocation and the one following it and then substract it from the rest of the content. I dunno if it's the best or most efficient way, but it's the esiest I know.
Find all posts by this user
Quote this message in a reply
Post Reply 



Contact UsTProgrammingReturn to TopReturn to ContentLite (Archive) ModeRSS Syndication