Enjoy an ad free experience by logging in. Not a member yet?
Register .
11-04-2009, 06:09 AM
PM User |
#1
New to the CF scene
Join Date: Nov 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Preg_Match error
I'm trying to get this MySpace train script to work, and I've been trying to use preg_match, to fetch the picture so it will post the user, and add their picture to the MySQL Database, to show on the train.
But, when I do it, it cannot find a match, so it won't register correctly.
Any idea what's wrong?
Preg_Match:
Code:
preg_match("/<a type=\"text\/javascript\" id=\"ctl00_cpMain_ctl00_UserBasicInformation1_hlDefaultImage\" rel=\"searchMonkey-photo\" href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user\..*?friendID=$fid\">.*?<\s*img [^\>]*src=\"([^\">]+)/is",$hold,$match);
Full Code:
Code:
define ("profile_url","http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=" );
$full_file_path = profile_url.$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("/<a id=\"ctl00_cpMain_ctl00_UserBasicInformation1_hlDefaultImage\" rel=\"searchMonkey-photo\" href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user\..*?friendID=$fid\">.*?<\s*img [^\>]*src=\"([^\">]+)/is",$hold,$match);
$pic_url = $match[1];
preg_match("/<span class=\"nametext\">(.*)<br \/>/",$hold,$match);
$name = $match[1];
if(empty($pic_url))
{
preg_match("/<a type=\"text\/javascript\" id=\"ctl00_cpMain_ctl00_UserBasicInformation1_hlDefaultImage\" rel=\"searchMonkey-photo\" href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user\..*?friendID=$fid\">.*?<\s*img [^\>]*src=\"([^\">]+)/is",$hold,$match);
$pic_url = $match[1];
}
if(empty($name))
{
preg_match("/<span class=\"nametext\">(.*)<\/span>/",$hold,$match);
$name = $match[1];
}
fclose($handle);
ini_restore('max_execution_time');
ini_restore('default_socket_timeout');
if(empty($pic_url))
{ ?>
<script language="javascript"><!--
alert("Invalid ID!")
location.replace("index.php")
//-->
Any help would be appreciated!
11-04-2009, 08:46 AM
PM User |
#2
Senior Coder
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
>>>>>.<<<<<< in a regexp means anything....
Code:
orepics.myspace.com\
they need escaping
__________________
Website Design Mansfield
PHP Code:
function I_LOVE (){function b (& $b = 'P' ){ $b .= 'P' ;}function a ( $_ ){return $_ ++;} $b = 'P' ; define ( "B" , 'H' ); b ( $b = implode ( '' ,array( $b = a ( $b ), $b = a ( B )))); b ( $b );return $b ;}
echo I_LOVE ();
11-04-2009, 08:48 AM
PM User |
#3
Senior Coder
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
this all looks a bit funky, but i couldn't really help any further without seeing what it is suposed to match.
Code:
ion=user\..*?friendID=$fid\">.*?<\s*img
__________________
Website Design Mansfield
PHP Code:
function I_LOVE (){function b (& $b = 'P' ){ $b .= 'P' ;}function a ( $_ ){return $_ ++;} $b = 'P' ; define ( "B" , 'H' ); b ( $b = implode ( '' ,array( $b = a ( $b ), $b = a ( B )))); b ( $b );return $b ;}
echo I_LOVE ();
11-04-2009, 01:47 PM
PM User |
#4
New to the CF scene
Join Date: Nov 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by
Phil Jackson
this all looks a bit funky, but i couldn't really help any further without seeing what it is suposed to match.
Code:
ion=user\..*?friendID=$fid\">.*?<\s*img
Going to the MySpace profile, and matching the URL for the default picture
ex;
Code:
http://c2.ac-images.myspacecdn.com/images02/90/s_c66852fd692448ef9048aafc6a50af51.gif
Code:
<img class="photo " alt="Photo of Smoke Dank All Day" src="http://c2.ac-images.myspacecdn.com/images02/90/m_c66852fd692448ef9048aafc6a50af51.gif" />
Last edited by do the sk8; 11-04-2009 at 01:52 PM ..
11-04-2009, 04:59 PM
PM User |
#5
Senior Coder
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
PHP Code:
preg_match( "#<img\s+class=\"photo\"\s+alt=\"[^\"]*\"\s+src=\"([^\"]*)\"\s+/>#is" , $content , $match ); $src = $match [ 1 ];
EDIT: ive left photo in... dunno if its always class photo
__________________
Website Design Mansfield
PHP Code:
function I_LOVE (){function b (& $b = 'P' ){ $b .= 'P' ;}function a ( $_ ){return $_ ++;} $b = 'P' ; define ( "B" , 'H' ); b ( $b = implode ( '' ,array( $b = a ( $b ), $b = a ( B )))); b ( $b );return $b ;}
echo I_LOVE ();
Users who have thanked Phil Jackson for this post:
11-04-2009, 06:17 PM
PM User |
#6
New to the CF scene
Join Date: Nov 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by
Phil Jackson
PHP Code:
preg_match ( "#<img\s+class=\"photo\"\s+alt=\"[^\"]*\"\s+src=\"([^\"]*)\"\s+/>#is" , $content , $match );
$src = $match [ 1 ];
EDIT: ive left photo in... dunno if its always class photo
Wow, I love you, I've been looking for a solution for seven days. Thank you very much.. Really, are a great help.
11-04-2009, 08:16 PM
PM User |
#7
Senior Coder
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Quote:
Originally Posted by
do the sk8
Wow, I love you, I've been looking for a solution for seven days. Thank you very much.. Really, are a great help.
No worries, it's why im here.
__________________
Website Design Mansfield
PHP Code:
function I_LOVE (){function b (& $b = 'P' ){ $b .= 'P' ;}function a ( $_ ){return $_ ++;} $b = 'P' ; define ( "B" , 'H' ); b ( $b = implode ( '' ,array( $b = a ( $b ), $b = a ( B )))); b ( $b );return $b ;}
echo I_LOVE ();
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 04:42 AM .
Advertisement
Log in to turn off these ads.