Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > Script Languages

Script Languages Perl/PHP/Python/Ruby so on and so forth.

Reply
 
Thread Tools Display Modes
Old 01-29-2007, 07:41 PM   #1 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default Need Help(Yes again) - getting text from remote page then turning into a variable

So theres a page that prints out TRUE or False depending on if a certain texts exists in the database...

(The source)
HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?>



<api>
	


		<gamertag>True</gamertag>


</api>
I was wondering if there was a way to read this page and if it displays True then print the desired text or if it says False then print something else...

I have been trying this:

PHP Code:
<?php
include 'gamercard.php';
$file 'http://www.360voice.com/api/gamertag-leaderboard.asp?tag='.$tag;
$fp fopen($file'r'); 
$users $data;
$data fread($fp80000);
$voice "Works";
//code that will grab the list of names/password and stores it in $users

if  ($users 'True')
{
print 
$voice;
} else {
print 
"Unfortuantly this GamerTag is not associated with the http://www.360voice.com website, so we can not display the requested information.";
}   
?>
But it just likes to put "Works" even if I use a known invalid tag
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.
Nott32 is offline   Reply With Quote
Old 01-29-2007, 08:25 PM   #2 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

Wait in a database or an XML file?
For an XML file, you could parse it real quick and just get the result...
mordero is offline   Reply With Quote
Old 01-29-2007, 09:30 PM   #3 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

Its the website...
http://www.360voice.com/api/gamertag...(Inserttaghere)

If your gamer tag is registered on 360voice.com it returns "True"

if it is not it returns "False"


http://www.360voice.com/api/gamertag...g=nott32Nott32

will return true because I am registered with 360voice.com

I jsut need the script to read if it says true or not so that it will not display errors if it is not valid (Just come up with a set message) and if it is valid it will display another PHP page(and or text)(Using include command)

EDIT: the link I used above was incoorect....sorry

http://www.360voice.com/api/gamertag-exists.asp?tag=
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.
Nott32 is offline   Reply With Quote
Old 01-29-2007, 09:43 PM   #4 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

actually it returns this
Code:
 <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <!-- Function to retrieve XML -->; 
- <!-- requires passed XSL -->; 
- <api>
- <info>
 <gamertag>Nott32</gamertag> 
 
 <score>1380</score> 
 
 <change>0</change> 
 
 <total>11</total> 
 
 <mostplayed>n/a</mostplayed> 
 
 </info>
 
 
- <leaderboards>
- <leaderboard name="gs">
 <name>Top Gamerscore</name> 
 
 <rank>52558</rank> 
 
 <url>http://www.360voice.com/leader-gs.asp?start=52557</url> 
 
 </leaderboard>
 
 
- <leaderboard name="gsc">
 <name>Daily Gamerscore Change</name> 
 
 <rank>45418</rank> 
 
 <url>http://www.360voice.com/leader-gsc.asp?start=45417</url> 
 
 </leaderboard>
 
 
- <leaderboard name="mpg">
 <name>Total Games Played</name> 
 
 <rank>58390</rank> 
 
 <url>http://www.360voice.com/leader-mpg.asp?start=58389</url> 
 
 </leaderboard>
 
 
 </leaderboards>
 
 
 </api>
if you are registered and this:
Code:
 <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <!-- Function to retrieve XML -->; 
- <!-- requires passed XSL -->; 
 <api />
so you could actually just see if the result contains "<api />". If it doesnt then, the person is registered there, if it does contain it, then the person isnt registered there

Last edited by mordero; 01-29-2007 at 09:45 PM.
mordero is offline   Reply With Quote
Old 01-29-2007, 09:46 PM   #5 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

ohhh lol, well the same thing, really there is no need to actually parse this since it is so short. Just check if the returned string contains "True" or "False"/"Invalid"
mordero is offline   Reply With Quote
Old 01-29-2007, 09:46 PM   #6 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

lol *Neb alert* how would I do that?

My Attmept:

PHP Code:
<?php 
include 'gamercard.php'
$file 'http://www.360voice.com/api/gamertag-exists.asp?tag='.$tag
$fp fopen($file'r');  
$users $data
$data fread($fp80000); 
$voice "Works"
//code that will grab the list of names/password and stores it in $users 

if  ($users 'True'

print 
$voice
} else { 
print 
"Unfortuantly this GamerTag is not associated with the http://www.360voice.com website, so we can not display the requested information."
}    
?>
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.

Last edited by Nott32; 01-29-2007 at 09:50 PM.
Nott32 is offline   Reply With Quote
Old 01-29-2007, 09:52 PM   #7 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

PHP: stristr - Manual <---
PHP Code:
$string "the result, whatever it may be";
if(
stristr($string'true') === FALSE) {
   
//the gamertag isnt registered here, so do that stuff
  
}
else
{
//it is registered here, so do that stuff

mordero is offline   Reply With Quote
Old 01-29-2007, 09:53 PM   #8 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

remember when you are checking to see if something is equivalent to something else to always use at least two =, other wise, it will reassign the variable you are trying to check and if that reassignment worked (which is almost always will for variables), returns true.
mordero is offline   Reply With Quote
Old 01-29-2007, 10:15 PM   #9 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

PHP Code:
<?php
//include 'gamercard.php';

$string 'http://www.360voice.com/api/gamertag-exists.asp?tag=Nott32';
if(
stristr($string'True') === FALSE) {
   echo 
'IN';//the gamertag isnt registered here, so do that stuff
  
}
else
{
echo 
'INx';
//it is registered here, so do that stuff
}  
?>
But it cant read from the URL?
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.
Nott32 is offline   Reply With Quote
Old 01-29-2007, 10:17 PM   #10 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

no, you need to open the file like you were earlier. and the do that if statement on your $data
mordero is offline   Reply With Quote
Old 01-29-2007, 10:20 PM   #11 (permalink)
Account Terminated
 
Join Date: Jun 2004
Location: Cincinnati, Ohio
Age: 20
Posts: 3,954
Default

Use PHP's XML parsing library.

Reading and writing the XML DOM with PHP

Or well, I guess if you just want that one tag, your solution works fine.
WarAngel is offline   Reply With Quote
Old 01-29-2007, 10:23 PM   #12 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

yeah, no point parsing it for just that one thing
mordero is offline   Reply With Quote
Old 01-29-2007, 10:24 PM   #13 (permalink)
Account Terminated
 
Join Date: Jun 2004
Location: Cincinnati, Ohio
Age: 20
Posts: 3,954
Default

Well if you decide you want some of the other tags, use my solution!
WarAngel is offline   Reply With Quote
Old 01-30-2007, 12:49 AM   #14 (permalink)
Master of the Internet
 
Join Date: Oct 2005
Age: 44
Posts: 6,283
Default

Frankly, I'm old, fat, and lazy, but given a chance to learn with a tool provided (by WarAngel), I think I'd try to implement a full parsing method so I could learn and make the code more easily used in the future.
__________________
Why is it that I'm never as smart as I thought I was yesterday?
My vast knowledge is only surpassed by my infinite ignorance.
<TheOutkastDev> i might have to hire an assassin to killl mal so that i can jump in front of the bullet and piss on him
Malaperth is offline   Reply With Quote
Old 01-30-2007, 01:40 AM   #15 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

but there isnt a reason to for that part, now once he checks if the gamertag exists and he wants to pull information from the other xml file, then yes, he should parse it, but for this, its a waste of resources
mordero is offline   Reply With Quote
Old 01-30-2007, 09:45 AM   #16 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

it works :-) It now checks the URL using a series of vatiables. I also figured out how to parse the gamer-leaderboards using preg_replace soI have one script that does all that and gets true/false. THanks Mordero! and thank you for the link WA.
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.
Nott32 is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5