Graxeon Posted October 8, 2009 Share Posted October 8, 2009 How can I get the URL in "Config/Media/Content/Video" from this XML file? Here are my attempts, but I'm messing up a lot :/. I don't get an error message...the page just keeps trying to load. <?php if (isset($_GET['url'])) { $converter = array('blankspot' => 'blanks', 'soccer' => '906', 'blankspothere' => 'blank'); $url = $_GET['url']; if (isset($converter[$url])) { $url='/flv_player/data/playerConfigEmbed/'.$converter[$url] . '.xml'; $sxml = simplexml_load_file($url); list($node) = $sxml->xpath('/config/media/content/video'); header('Location: '.$node['url']); exit; } } ?> And an edit: <?php $url='/flv_player/data/playerConfigEmbed/'.$converter[$url] . '.xml'; $string = file_get_contents($url); $sxml = new SimpleXmlElement($string); $node = $sxml->config->media->content->video()->SD; header('Location: '.$node); exit; } } ?> Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/ Share on other sites More sharing options...
ToonMariner Posted October 8, 2009 Share Posted October 8, 2009 list(,$node) = $sxml->xpath('/config/media/content/video'); see if that works Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-933343 Share on other sites More sharing options...
mrMarcus Posted October 8, 2009 Share Posted October 8, 2009 try this: $xmlContent = 'http://www.sqweasel.com/flv_player/data/playerConfigEmbed/906.xml'; $xml = @simplexml_load_file ($xmlContent); if ($xml): echo (string)$xml->media->content->video['SD']; endif; will get you started; Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-933344 Share on other sites More sharing options...
Graxeon Posted October 8, 2009 Author Share Posted October 8, 2009 I'm bad at this :/ So like this? <?php if (isset($_GET['url'])) { $converter = array('blankspot' => 'blanks', 'soccer' => '906', 'blankspothere' => 'blank'); $url = $_GET['url']; if (isset($converter[$url])) { $xmlContent = '/flv_player/data/playerConfigEmbed/'.$converter[$url] . '.xml'; $xml = @simplexml_load_file ($xmlContent); if ($xml): echo (string)$xml->media->content->video['SD']; endif; } } header("Location: http://www.sqweasel.com/"); ?> That should just print the URL from what I understand. But it doesn't...again it just keeps loading (and nothing is actually loading). If I can get it to print then directing to it is easy. Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-933367 Share on other sites More sharing options...
mrMarcus Posted October 8, 2009 Share Posted October 8, 2009 are you sure '/flv_player/data/playerConfigEmbed/'.$converter[$url] . '.xml' is the correct URL .. have you tried echo'ing out $xmlContent to make sure your $converter[$url] is right? your header() redirect, why is that there? that's just going to redirect you right off that page (and possibly into an infinite loop if you script is on the homepage) .. lose that redirect, or put it in a condition. Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-933372 Share on other sites More sharing options...
Graxeon Posted October 8, 2009 Author Share Posted October 8, 2009 The header redirect at the very bottom leads to the home page in case one of the inputs are not allowed. Example: file.php?url=soccer is allowed. file.php?url=1234 is not allowed so it redirects to the homepage. Now, if "soccer" was entered then the file would take the contents (config/media/content/video SD) from http://www.sqweasel.com/flv_player/data/playerConfigEmbed/906.xml. Then, the script would direct the user to that content (in this case, http://www.sqweasel.com/files/70dd27861e3dea2d.flv, which is in the "video SD" tag). So how would I go about doing this? I tried but can't seem to get the coding right. Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-933383 Share on other sites More sharing options...
dreamwest Posted October 8, 2009 Share Posted October 8, 2009 You dont need an xml list to redirect for a file download function redirect( $url ){ if (! headers_sent( ) ){ header( "Location: ".$url ); exit( 0 ); } echo "<script language=Javascript>document.location.href='".$url."';</script>"; exit( 0 ); } redirect("http://www.sqweasel.com/files/70dd27861e3dea2d.flv"); and in htaccess force the download # instruct browser to download multimedia files AddType application/octet-stream .avi AddType application/octet-stream .mpg AddType application/octet-stream .wmv AddType application/octet-stream .mp4 AddType application/octet-stream .mov Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-933396 Share on other sites More sharing options...
Graxeon Posted October 8, 2009 Author Share Posted October 8, 2009 Oh no, it's not for a download. It's a way of embedding it in a different way. I just need to find out how to make my script work. Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-933398 Share on other sites More sharing options...
Graxeon Posted October 9, 2009 Author Share Posted October 9, 2009 So umm...can anyone explain it to me, please? I tried Toon's and Marcus's code but couldn't get it right. Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-933872 Share on other sites More sharing options...
Graxeon Posted October 10, 2009 Author Share Posted October 10, 2009 Bump. Anyone? Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-934254 Share on other sites More sharing options...
thebadbad Posted October 10, 2009 Share Posted October 10, 2009 Can't see why this shouldn't work: <?php if (isset($_GET['url'])) { $converter = array( 'blankspot' => 'blanks', 'soccer' => '906', 'blankspothere' => 'blank' ); $url = $_GET['url']; if (isset($converter[$url])) { $xml = @simplexml_load_file('/flv_player/data/playerConfigEmbed/' . $converter[$url] . '.xml'); if ($xml) { echo (string) $xml->media->content->video['SD']; exit; } } } header('Location: http://www.sqweasel.com/'); ?> Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-934282 Share on other sites More sharing options...
Graxeon Posted October 14, 2009 Author Share Posted October 14, 2009 That just takes me to the homepage. Edit: Oh wait, nevermind. Give me a sec. Edit2: Works, ty! Link to comment https://forums.phpfreaks.com/topic/177014-solved-loading-url-from-xml/#findComment-936553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.