User:Ugleh Ulrik/Name2Key

From Second Life Wiki
< User:Ugleh Ulrik
Revision as of 14:21, 16 May 2010 by Ugleh Ulrik (talk | contribs) (Created page with ''''This PHP Code will search Second Lifes database and bring back the persons Key''' This script uses Curl to grab the data because ive tested and Curl goes much faster. <php> <...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This PHP Code will search Second Lifes database and bring back the persons Key This script uses Curl to grab the data because ive tested and Curl goes much faster.

<php> <?php $p = $_GET['q']; $user = implode("+", explode(' ', $p)); $url = "http://search.secondlife.com/web/search/?q=$user"; $useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE ); // return into a variable curl_setopt($ch, CURLOPT_HEADER, 0); $result = curl_exec( $ch ); // run! curl_close($ch);

$newlines = array(">", "<", "/", "=", "\n"); $content = str_replace($newlines, "", html_entity_decode($result)); $content = stripslashes(preg_replace('/\s\s+/', , $content)); $html = '/world.secondlife.comresident(.+?)ah/'; preg_match($html,$content,$raw); $example = $raw[1]; $key = split('"', $example); echo $key[0]; ?> </php>

Upload this PHP file and then go to the url with a GET of q=User Name