Jump to content

[SOLVED] Trying to isolate a MySpace user ID# with preg_match


deleet

Recommended Posts

Hello everyone.  I do a lot of work with PHP string processing but this latest project knocked me for a loop.  I just learned a little about preg_match yesterday and haven't been really able to adapt.  I'm at the point where I got rid of the error messages but I just need to wire the variables up so I get an effective answer.

 

Here's what the original code was, give or take a few brackets.

 

<?PHP
}
else {
define ("profile_url","http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=" );

$full_file_path = profile_url.$rider_fid;

$handle = fopen($full_file_path,"r");

if (!$handle){

    	echo "<p>Sorry Myspace Is Slow Try Again.\n";

    	$arr = 0; }

else {

$timeout = 300;

ini_set('max_execution_time','120');

set_time_limit(120);

ini_set('default_socket_timeout','120');

while($contents = fread($handle,'1024'))

{ $hold .= $contents; }

preg_match(long long procedure);

$string_ahref = $match[1];

$subjectstr = substr($string_ahref,0,350);

	}


	fclose($handle);

	ini_restore('max_execution_time');

	ini_restore('default_socket_timeout');

	$pic = $pic_url;


	if(empty($pic_url))
	{ ?>



 

I tried to make my own version up:

 

<?PHP

define ("profile_url","http://myspace.com/" );
$rider_fid="mucklejohndotcom"; //just an example tack-on -- completed version will have user input this

$full_file_path = profile_url.$rider_fid; //combine base url with user's URL

$handle = fopen($full_file_path,"r");

if (!$handle){

    	echo "<p>Sorry, MySpace Is Slow.  Please Try Again.\n";

    	$arr = 0; }             //ARRRR!!

else {

$timeout = 300;

ini_set('max_execution_time','120');

set_time_limit(120);

ini_set('default_socket_timeout','120');

while($contents = fread($handle,'1024'))

{ $hold .= $contents; }
$duh=preg_match("/DisplayFriendId/i",$url['$handle'],$hold,$match);

// preg_match("/\bDisplayFriendId/i",$url['$handle'],$hold,$match); ?


print_r($duh);
$tester1 = $match[0];
  $tester2 = $match[1];
  // Just trying to get anything to print and it's not...
echo $tester2;
  echo $tester1;}

?>

 

What I was looking to do was have the code crawl the MySpace page, find "DisplayFriendId":XXXXXXX, and then extract the ID number between "Display..." and the comma, so I would be able to plug this ID into the original code, which crawled the site by user's ID number instead of MySpace URL.  All I get is a 0 for results, but as far as I know, MySpace is working fine. :D

 

Any help would be appreciated.  I'm able to parse out the string, so I'm all set with that.  Just trying to make preg_match pull the ID and understand how to retrieve the variable... Thanks.

Link to comment
Share on other sites

MySpaceRes.Header = {"Cancel":"Cancel / Cancelación","Continue":"Continue / Continuar"};
MySpace.ClientContext = {"UserId":-1,"DisplayFriendId":10751728,"IsLoggedIn":false,"FunctionalContext":"UserViewProfile","UserType":1};

MySpace.StaticContentBase='http://x.myspacecdn.com';

MySpace.ClientMaintenanceConfigs = 

Link to comment
Share on other sites

// example of the content...
$string = <<<CONTENT
MySpaceRes.Header = {"Cancel":"Cancel / Cancelación","Continue":"Continue / Continuar"};
MySpace.ClientContext = {"UserId":-1,"DisplayFriendId":10751728,"IsLoggedIn":false,"FunctionalContext":"UserViewProfile","UserType":1};

   MySpace.StaticContentBase='http://x.myspacecdn.com';
   
MySpace.ClientMaintenanceConfigs = 
CONTENT;
preg_match('~"DisplayFriendId"\d+),~i',$string,$match);
echo $match[1];

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.