'; // Initialise cURL. $curl = curl_init(); //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // Get their profile page (to get their ID). echo ' Retrieving profile... '; curl_setopt($curl, CURLOPT_URL, 'http://myspace.com/' . $_POST['url']); curl_setopt($curl, CURLOPT_POST, 0); $result = curl_exec($curl); $headers = curl_getinfo($curl); // Is it private? if (strpos($result, 'This profile is set to private')) { echo 'Error: Your profile is set as private. Currently, private profiles are not supported by this script.'; return false; } echo 'Done, took ', $headers['total_time'], ' seconds. '; // Get their ID. //if (!preg_match('/fuseaction=user\.viewfriends&friendID=([0-9]+)">/', $result, $matches)) if (!preg_match('/fuseaction=user\.viewfriends&friendID=([0-9]+)">/', $result, $matches)) { echo 'Error: Could not retrieve friend ID! Please report this to myspace@daniel15.com. Be sure to mention your URL in the email.'; print_r($matches); //echo $result; return false; } $id = $matches[1]; unset($matches); echo 'Your Friend ID is ', $id, '.
'; // Retrieve friends page. echo 'Checking friends list... '; curl_setopt($curl, CURLOPT_URL, 'http://friends.myspace.com/index.cfm?fuseaction=user.viewfriends&friendID=' . $id); curl_setopt($curl, CURLOPT_POST, 0); $result = curl_exec($curl); $headers = curl_getinfo($curl); // Find out how many pages there are. preg_match('/
of <\/div>(.+)<\/a>/', $result, $matches); $pages = $matches[2]; unset($matches); echo 'You have ', $pages, ' pages of friends.
'; // Get the viewstate. preg_match('//', $result, $matches); $viewstate = $matches[1]; unset($matches); // Get the "msPagerState". preg_match('//', $result, $matches); $mspagerstate = $matches[1]; unset($matches); // Start with an empty list of friends $friends = array(); // Process all pages. for ($i = 1; $i <= $pages; $i++) { echo 'Page ', $i, '... '; flush(); // Get this page. curl_setopt($curl, CURLOPT_URL, 'http://friends.myspace.com/index.cfm?fuseaction=user.viewfriends&friendID=' . $id); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, '__EVENTTARGET=ctl00$cpMain$pagerTop&__EVENTARGUMENT=' . $i . '&__LASTFOCUS=&__VIEWSTATE=' . $viewstate . '&ctl00$Main$rblSearchType=Display+Name&ctl00$Main$txtSearch=&___msPagerState=' . $mspagerstate . '&ctl00$Main$ddlSearch=Display&ctl00$Main$ddlHidden=0&ctl00$Main$seletedAlpha=&ctl00$Main$editMode=false'); $result = curl_exec($curl); //$headers = curl_getinfo($curl); // Was this request a broken one? if (strpos($result, 'HTTP Error 404 - File or directory not found')) { echo 'Error occurred, retrying...'; $i--; continue; } // Get all the users on this page. /*preg_match_all('/
(.+?)<\/a>\r\n
\r\n
(.+?)<\/a>/', $result, $matches, PREG_SET_ORDER);*/ preg_match_all('/(.+?)<\/a>\r\n
\r\n
\r\n (.+?)<\/a>/', $result, $matches, PREG_SET_ORDER); // Loop through each friend on this page. foreach ($matches as $friend) { // Add them to the friends array $friends[] = array( 'id' => $friend[2], 'name' => $friend[1], 'picture' => $friend[5], ); } //print_r($matches); //echo '
', htmlentities($result), '
'; //echo $result; // Get the viewstate. preg_match('//', $result, $matches); $viewstate = $matches[1]; unset($matches); // Get the "msPagerState". preg_match('//', $result, $matches); $mspagerstate = $matches[1]; unset($matches); } echo '

', count($friends), ' friends found for ', htmlentities($_POST['url']), '.

    '; foreach ($friends as $friend) { //print_r($friend); echo '
  1. '; if (!empty($_POST['photos'])) echo '
    '; echo '', $friend['name'], '

  2. '; } echo '

'; return true; } ?> MySpace Friends List Export

MySpace Friends List Export


For example, if your MySpace URL is http://myspace.com/daniel_1515, then your username is daniel_1515.


If selected, each user will have their picture displayed above their name. Note that if you have a lot of friends, this will make the page take a significant amount of time to load.

Problems? Report any errors to myspace -[at]- daniel15.com (replace -[at]- with @)