bustya
02-01-2008, 06:13 PM
Sounds simple enough, but I can't get it working. What I'm trying to accomplish here is to first check the url (to the file) to see if it's valid, if so I want to read the url found in the file's embed tag and then write it to an object tag.
This is to retrieve a myspace band mediaplayer. I don't want the entire object from myspace because I want to change the size of the object I'm going to echo.
So basically I want to read the page, retrieve the url from the embed and use that url in my own object tag.
Here's a sample of the code as it is on myspace, this is the entire object, but I just need the url in the embed tag....
<OBJECT id="mp3player" codeBase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab##version=8,0,0,0"
height="345" width="450" border="0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
VIEWASTEXT>
<PARAM NAME="_cx" VALUE="11906">
<PARAM NAME="_cy" VALUE="9128">
<param name="FlashVars" value="culture=en-US" />
<PARAM NAME="Movie" VALUE="http://lads.myspace.com/music/musicplayer.swf?n=aHR0cDovL211c2ljLm15c3BhY2UuY29t&t=lBupI3PXcwP0zfuzSQhr6cciFVqGNE8HgoT7HiVxolb6QF+rHo57DjLKAB/cg4u+yZigshK1U9b9iJR3az+YIA==&u=LTE=&a=0&d=MTM0MDIwNDcwXjEyMDE4ODIxOTI=">
<PARAM NAME="Src" VALUE="http://lads.myspace.com/music/musicplayer.swf?n=aHR0cDovL211c2ljLm15c3BhY2UuY29t&t=Qd15jlyjjVzXW+MzKr4kTt8b2vx98BnFkjbo0tSaW3XbI95SFyaaF8VXtCx+1p+TJu3ZvrL3/MQWKw4bUn4+Qg==&u=LTE=&a=0&d=MTM0MDIwNDcwXjEyMDE4ODIxOTI=">
<PARAM NAME="WMode" VALUE="Window">
<PARAM NAME="Play" VALUE="-1">
<PARAM NAME="Loop" VALUE="-1">
<PARAM NAME="Quality" VALUE="High">
<PARAM NAME="SAlign" VALUE="">
<PARAM NAME="Menu" VALUE="-1">
<PARAM NAME="Base" VALUE="">
<PARAM NAME="AllowScriptAccess" VALUE="always">
<PARAM NAME="Scale" VALUE="ShowAll">
<PARAM NAME="DeviceFont" VALUE="0">
<PARAM NAME="EmbedMovie" VALUE="0">
<PARAM NAME="BGColor" VALUE="#FFF">
<PARAM NAME="SWRemote" VALUE="">
<PARAM NAME="MovieData" VALUE="">
<PARAM NAME="SeamlessTabbing" VALUE="1">
<embed src="http://lads.myspace.com/music/musicplayer.swf?n=aHR0cDovL211c2ljLm15c3BhY2UuY29t&t=j8ASSojSr0Gd3BARpJ/3WCFe+CtSyYjl0VY9/CsqpYo/9gAW9JiXb1okplxRG1OUtg1ywNlsIxRBnA928TB+Hw==&u=LTE=&a=0&d=MTM0MDIwNDcwXjEyMDE4ODIxOTI=" quality=high bgcolor=#FFFFFF
width="450" height="345" name="mp3player" align="" AllowScriptAccess="always"
type="application/x-shockwave-flash" FlashVars="culture=en-US"
pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed>
</OBJECT>
Now here's the code I'm working on, this reads/echos the entire page, not what I want, but close.
<?php
// set file to read
$file = 'http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=134020470';
// read file into string
$data = file_get_contents($file) or die('Could not read file!');
// print contents
echo $data;
?>
I tried adding preg_match to the above but to no avail, something like so:
<?php
// set file to read
$file = 'http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=134020470';
// read file into string
$player = preg_match("/<embed src=\"(.*)\"*><\/embed>/", $file);
$data = file_get_contents($player) or die('Could not read file!');
// print contents
echo $data;
?>
The above returns a '0', as in nothing in the array. Any ideas?
Also, there's one last thing to consider. If the object (embed) no longer exists on the myspace page, i need to return text instead of a broken object.
This is to retrieve a myspace band mediaplayer. I don't want the entire object from myspace because I want to change the size of the object I'm going to echo.
So basically I want to read the page, retrieve the url from the embed and use that url in my own object tag.
Here's a sample of the code as it is on myspace, this is the entire object, but I just need the url in the embed tag....
<OBJECT id="mp3player" codeBase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab##version=8,0,0,0"
height="345" width="450" border="0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
VIEWASTEXT>
<PARAM NAME="_cx" VALUE="11906">
<PARAM NAME="_cy" VALUE="9128">
<param name="FlashVars" value="culture=en-US" />
<PARAM NAME="Movie" VALUE="http://lads.myspace.com/music/musicplayer.swf?n=aHR0cDovL211c2ljLm15c3BhY2UuY29t&t=lBupI3PXcwP0zfuzSQhr6cciFVqGNE8HgoT7HiVxolb6QF+rHo57DjLKAB/cg4u+yZigshK1U9b9iJR3az+YIA==&u=LTE=&a=0&d=MTM0MDIwNDcwXjEyMDE4ODIxOTI=">
<PARAM NAME="Src" VALUE="http://lads.myspace.com/music/musicplayer.swf?n=aHR0cDovL211c2ljLm15c3BhY2UuY29t&t=Qd15jlyjjVzXW+MzKr4kTt8b2vx98BnFkjbo0tSaW3XbI95SFyaaF8VXtCx+1p+TJu3ZvrL3/MQWKw4bUn4+Qg==&u=LTE=&a=0&d=MTM0MDIwNDcwXjEyMDE4ODIxOTI=">
<PARAM NAME="WMode" VALUE="Window">
<PARAM NAME="Play" VALUE="-1">
<PARAM NAME="Loop" VALUE="-1">
<PARAM NAME="Quality" VALUE="High">
<PARAM NAME="SAlign" VALUE="">
<PARAM NAME="Menu" VALUE="-1">
<PARAM NAME="Base" VALUE="">
<PARAM NAME="AllowScriptAccess" VALUE="always">
<PARAM NAME="Scale" VALUE="ShowAll">
<PARAM NAME="DeviceFont" VALUE="0">
<PARAM NAME="EmbedMovie" VALUE="0">
<PARAM NAME="BGColor" VALUE="#FFF">
<PARAM NAME="SWRemote" VALUE="">
<PARAM NAME="MovieData" VALUE="">
<PARAM NAME="SeamlessTabbing" VALUE="1">
<embed src="http://lads.myspace.com/music/musicplayer.swf?n=aHR0cDovL211c2ljLm15c3BhY2UuY29t&t=j8ASSojSr0Gd3BARpJ/3WCFe+CtSyYjl0VY9/CsqpYo/9gAW9JiXb1okplxRG1OUtg1ywNlsIxRBnA928TB+Hw==&u=LTE=&a=0&d=MTM0MDIwNDcwXjEyMDE4ODIxOTI=" quality=high bgcolor=#FFFFFF
width="450" height="345" name="mp3player" align="" AllowScriptAccess="always"
type="application/x-shockwave-flash" FlashVars="culture=en-US"
pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed>
</OBJECT>
Now here's the code I'm working on, this reads/echos the entire page, not what I want, but close.
<?php
// set file to read
$file = 'http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=134020470';
// read file into string
$data = file_get_contents($file) or die('Could not read file!');
// print contents
echo $data;
?>
I tried adding preg_match to the above but to no avail, something like so:
<?php
// set file to read
$file = 'http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=134020470';
// read file into string
$player = preg_match("/<embed src=\"(.*)\"*><\/embed>/", $file);
$data = file_get_contents($player) or die('Could not read file!');
// print contents
echo $data;
?>
The above returns a '0', as in nothing in the array. Any ideas?
Also, there's one last thing to consider. If the object (embed) no longer exists on the myspace page, i need to return text instead of a broken object.