Difference between revisions of "User:Crooked Shim"
Jump to navigation
Jump to search
Crooked Shim (talk | contribs) m (moved User talk:Crooked Shim to User:Crooked Shim: Oops) |
Crooked Shim (talk | contribs) |
||
Line 13: | Line 13: | ||
$url = sprintf('http://search.secondlife.com/web/search/?q=%s', urlencode($user_name)); | $url = sprintf('http://search.secondlife.com/web/search/?q=%s', urlencode($user_name)); | ||
$ch = curl_init(); | $ch = curl_init(); | ||
curl_setopt_array($ch, array(CURLOPT_URL=>$url, CURLOPT_RETURNTRANSFER=>true, CURLOPT_CONNECTTIMEOUT=>5, CURLOPT_USERAGENT=>" | curl_setopt_array($ch, array(CURLOPT_URL=>$url, CURLOPT_RETURNTRANSFER=>true, CURLOPT_CONNECTTIMEOUT=>5, CURLOPT_USERAGENT=>"Name2Key")); | ||
$output = curl_exec($ch); | $output = curl_exec($ch); | ||
curl_close($ch); | curl_close($ch); |
Revision as of 19:48, 6 May 2010
Useful PHP FunctionsThese may break at any time, depends on if LL changes SL search too much. Name2Keyfunction get_key($user_name) { $url = sprintf('http://search.secondlife.com/web/search/?q=%s', urlencode($user_name)); $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL=>$url, CURLOPT_RETURNTRANSFER=>true, CURLOPT_CONNECTTIMEOUT=>5, CURLOPT_USERAGENT=>"Name2Key")); $output = curl_exec($ch); curl_close($ch); $user_name = strtoupper($user_name); preg_match_all('%<a href="http://world\.secondlife\.com/resident/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})">(?:<b>)?(.+?)(?:</b>)?</a>%', $output, $matches, PREG_SET_ORDER); foreach ($matches as $val) { if (strtoupper($val[2]) == $user_name) { return $val[1]; } } return 'not_found'; } Key2Namefunction get_name($user_key) { $url = sprintf('http://world.secondlife.com/resident/%s', urlencode($user_key)); $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL=>$url, CURLOPT_RETURNTRANSFER=>true, CURLOPT_CONNECTTIMEOUT=>5)); $output = curl_exec($ch); curl_close($ch); preg_match('%<title>(.+?)</title>%', $output, $matches); if (!empty($matches[1])) return $matches[1]; else return 'not_found'; } Key2Birthdayfunction get_birthday($user_key) { $url = sprintf('http://world.secondlife.com/resident/%s', urlencode($user_key)); $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL=>$url, CURLOPT_RETURNTRANSFER=>true, CURLOPT_CONNECTTIMEOUT=>5, CURLOPT_USERAGENT=>"Madgeek_K2DOB")); $output = curl_exec($ch); curl_close($ch); if (strpos($output, 'AccessDenied') !== false) return 'not_found'; if (preg_match('%<span class="syscat">Resident Since:</span>\s<!--googleon: index-->\s(\d+?)-(\d+?)-(\d+?)\s<!--googleoff: index-->%', $output, $matches)) return array_slice($matches, 1); else return 'not_found'; } |