PDA

View Full Version : Need php script that converts Myspace name to FriendID


clickfast
June 4th, 2007, 11:35 PM
I need a simple script that allows a user to enter myspace.com/bandname, click go and it retrieves their friend id.

There are tons of sites that have this already ...myspacegens.com is one

Hoping to find a PHP version. I am not a PHP programmer however. Just a website admin working for a client

Thanks

marshall_26
June 5th, 2007, 06:02 AM
I need a simple script that allows a user to enter myspace.com/bandname, click go and it retrieves their friend id.

There are tons of sites that have this already ...myspacegens.com is one

Hoping to find a PHP version. I am not a PHP programmer however. Just a website admin working for a client

Thanks
<?php
echo '<table border="1"><tr>';
if(!$_POST['id']){echo'<td><span style="color:#000;font-weight:bold;">Find User ID: </span></td>';}
if($_POST['id']){
$pro = 'http://myspace.com/'.$_POST['id'];
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $pro);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
curl_close ($ch);
preg_match('/invite.addfriend_verify&friendID=[0-9]{8}/is', $result, $found);

if($found != FALSE){
$start = implode("", $found);
list($junk, $id) = explode("=", $start);
echo '<td><span style="color:green;font-weight:bold;">User ID: '.$id.'</span></td>';}
else{echo'<td><span style="color:red;font-weight:bold;">User ID Not found!</span></td>';}
}
echo'<form method="post" action="'.$_SERVER['php_self'].'">
<td><input type="text" size="15" name="id"></td>
<td><input type="submit" value="Go" style="background:#FFF;border:1px solid #000;"></td>
</form></tr></table>';
?>

Took a whole 10 mins :)

George
June 5th, 2007, 06:25 AM
Very cool of you to share +rep for you.

marshall_26
June 5th, 2007, 06:39 AM
Very cool of you to share +rep for you.
Thanks :clap:

alltheRAGE
June 5th, 2007, 07:37 AM
Thanks for that code! Have already put it on my site. Giving you some green rep too :)

omen
June 5th, 2007, 08:35 AM
Wow, marshall_26 for resident PHP coder :D

Thanks for that!

clickfast
June 5th, 2007, 09:12 AM
Super Marshall! You are the best! Much respect and tons of Green!!!

marshall_26
June 5th, 2007, 11:36 AM
Replace

preg_match('/invite.addfriend_verify&friendID=[0-9]{8}/is', $result, $found);

with

preg_match('/\binvite.addfriend_verify&friendID=[0-9]{1,15}\b/is', $result, $found);

It is basically a regex string match for

invite.addfriend_verify&friendID= , and any numbers, but only {8} of them

So basically if there is 9 digits only 8 would be returned, or if only 7 or less digits it would fail the match.

Sorry I was in a hurry :)

Greg-J
June 5th, 2007, 01:10 PM
Now this is the type of contributions I'll be looking at when deciding who gets the wii.

rize
June 5th, 2007, 02:42 PM
ohh cool thanks for that..:)

marshall_26
June 5th, 2007, 10:19 PM
Thanks and welcome ... I appreciate all the green, although my bar seems to dance around alot :? Anyway anyone interested in learning PHP to better their site should really look into learning how PHP CURL works it does a great job at getting the data you desire, it really is a great tool for retrieving myspace info!

deep
June 5th, 2007, 10:24 PM
nice job on the code :)

money_train
June 5th, 2007, 10:47 PM
great script.
but can any one show this working live on their site.
i am a no whiz at php or anything.:(

Assailant
June 5th, 2007, 10:48 PM
www.layoutsnetwork.com/id.php