lllpumaslll Posted October 11, 2007 Share Posted October 11, 2007 Having a problem getting a proper match from this: preg_match("/<a id=\"ctl00_Main_ctl00_UserBasicInformation1_hlDefaultImage\" href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user\..*?friendID=$friend_id\">.*?<img src=\"(.*?)\"><\/a\>/is",$buff,$match); This is the whole code: <?php class socket { function GetFromMyspace($friend_id) { $full_file_path = MYSPACE_PROFILE_PATH.$friend_id; $handle = fopen($full_file_path,"r"); if (!$handle) { echo "<p>Unable to open remote file.\n"; $arr = 0; } else { $timeout = 300; //$old = ini_set('default_socket_timeout', $timeout); // ini_set('default_socket_timeout', $old); //stream_set_timeout($handle, $timeout); //stream_set_blocking($handle, 0); // set_time_limit(120); ini_set('max_execution_time','120'); set_time_limit(120); ini_set('default_socket_timeout','120'); while($contents = fread($handle,'1024')) { $buff .= $contents; } //echo "buff--> = ".$buff."--------->"; preg_match("/<a id=\"ctl00_Main_ctl00_UserBasicInformation1_hlDefaultImage\" href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user\..*?friendID=$friend_id\">.*?<img src=\"(.*?)\"><\/a\>/is",$buff,$match); $string_ahref = $match[0]; //echo "string = ".$string_ahref; $substr = substr($string_ahref,0,350); $trimed = strip_tags($substr,"<img>"); $trimed = trim($trimed); //echo "strip".$trimed; $len = strlen($trimed); //echo "length".$len."<br>"; $image_name = substr($trimed,10,($len-25)); //echo "<br><br>imname= '".$image_name."'<br>"; preg_match("/<span class=\"nametext\".*>?<\/span>/is",$buff,$match_name); //echo "name= ".$match_name[0]; if(empty($image_name)) { $img_name = substr($match_name[0],100,600); $img = strip_tags($img_name,"<img>"); //echo "strip-->".$img."<--"; $img = trim($img); $len = strlen($img); //echo "length".$len."<br>"; $image_name = substr($img,10,($len-25)); $image_name = trim($image_name); //echo "ooo".$img."000"; //echo "Image = ->".$image_name."<--"; } //echo "<br><br>imname= '".$image_name."'<br>"; if(substr($image_name,0,10)=="<img src=\"") { $third_name = substr($image_name,10,strlen($image_name)); //echo "third = ".$third_name; $image_name = $third_name; } //echo "<br><br>imname= '".$image_name."'<br>"; $subname = substr($match_name[0],0,200); $name = strip_tags($subname,"<span>"); $name = trim($name); $len_name = strlen($name); // echo $len_name; $name_final = substr($name,23,($len_name-30)); $arr = array("name"=>$name_final,"imagepath"=>$image_name); //exit(); } fclose($handle); ini_restore('max_execution_time'); ini_restore('default_socket_timeout'); return $arr; } } ?> Quote Link to comment Share on other sites More sharing options...
lllpumaslll Posted October 12, 2007 Author Share Posted October 12, 2007 Anyone know about preg_match or have any input on my problem? Quote Link to comment Share on other sites More sharing options...
lllpumaslll Posted October 12, 2007 Author Share Posted October 12, 2007 Ok, maybe I need to explain it a little more and see if this makes sense: Whenever someone enters their id # ("$friend_id"), that id number will retrieve their default picture from their myspace profile. For example, lets says their id # is 2: http://viewmorepics.myspace.com/index.cfm?fuseaction=user.viewAlbums&friendID=2 The code is supposed to retrieve the default image of id # 2: http://b4.ac-images.myspacecdn.com/00006/41/73/6343714_m.JPG Quote Link to comment Share on other sites More sharing options...
effigy Posted October 12, 2007 Share Posted October 12, 2007 Is the content being retrieved properly (is the match actually in there)? What kind of errors are you getting, if any? Quote Link to comment Share on other sites More sharing options...
lllpumaslll Posted October 12, 2007 Author Share Posted October 12, 2007 Is the content being retrieved properly (is the match actually in there)? What kind of errors are you getting, if any? Well, the above code was working until myspace changed something. I was told it was the tags (but again I could be wrong). Which means they changed the default image path. Therefore that code doesnt match with the new path. I'm getting this (example): <img src="r="0" alt="" src="http://a377.ac-images.myspacecdn.com/images01/87/m_99b80c3a90d0c58c0596fee47" width="100" height="100" border="0" class="fade"> When I should be getting this: <img src="http://a377.ac-images.myspacecdn.com/images01/87/m_99b80c3a90d0c58c0596fee4711380d0.jpg" width="100" height="100" border="0" class="fade"> Quote Link to comment Share on other sites More sharing options...
effigy Posted October 12, 2007 Share Posted October 12, 2007 The match on img should be flexible in order to encompass attribute changes. /<img[^>]+src="(.*?)"[^>]*>/ Quote Link to comment Share on other sites More sharing options...
sitesadmin Posted October 12, 2007 Share Posted October 12, 2007 you have the same issue i didnt even see this. but its only music profiles that i have problem with Quote Link to comment Share on other sites More sharing options...
lllpumaslll Posted October 12, 2007 Author Share Posted October 12, 2007 Well, thanks dude. 1 problem less. Now we have to figure why its doing that for band profiles. I think the problem may be what my buddy effigy said about attributes. But I really dont know anything about php. Quote Link to comment Share on other sites More sharing options...
sitesadmin Posted October 17, 2007 Share Posted October 17, 2007 So did you fix this? can you help me out here please Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.