Jump to content
#StayAtHome ×

darklexus2k9

Members
  • Content Count

    36
  • Joined

  • Last visited

Community Reputation

0 Neutral

About darklexus2k9

  • Rank
    Member

Profile Information

  • Gender
    Not Telling
  1. i fixed the issue god knows what is wrong but simplexml refused to read the code from the remote source it was all being tml encoded when loaded by simplexml for some reason meaning it couldnt find the child eliments i have decided to change the code a little and i am now loading it by setting up a new dom and doin it that way and all seem to be good with that so am guessing there must be issues with server files or something for the simplexml god knows but all working good now thanks for all the help guys
  2. going by the responce froom the server i am guessing nothing is broken or wrong i am guessing the company that makes the output has there own program that looks for each line on its own and works on that and does not work on it as the one big string wouldnt be the first company i have seen so this in fact itv in the uk use todo something along the same lines with there ios api they had 3 diffrent json responces returned in the one request there app simply treated each line in the responce as a new json object to be decoded and displayed as for the work around yes it is messy and could affect other things but bassed on the returned json and going by what the user has said i assume the respone is generaly the same kind of output for all requests and there for should work fine for what he needes todo for now if things become more complex then the user would need to post the other possible outputs to determin what would be needed but for now be it messy or not it should work and be the most simle way for the users todo what they need todo
  3. ok i have done some editing on my code to remove some un needed junk such as the stupid ( now : show info ) form the channel names and also removed the <description> show decription here</description> this now shows as <description>null</description> i have now eliminated every un know chars other than a-z 1-0 ://=_ witch are used in channel names logos urls but i dont think they should create any issues with the xml when i do a quick test by dumping the requested data after these edit it all looks good in the browser and all looks good in the view-source: web broswer page as well now i notice the issue seems to happen as soon as i try load this data into simple xml as a string this is when my error file starts spitting out stuff like [07-Apr-2017 22:31:32 UTC] PHP Warning: simplexml_load_string(): Entity: line 1567: parser error : xmlParseEntityRef: no name in /home/****/public_html/m3u.php on line 24 [07-Apr-2017 22:31:32 UTC] PHP Warning: simplexml_load_string(): <name>Sky Action & Adventure</name> in /home/****/public_html/m3u.php on line 24 the thing to notice is that the error is showing it as <name>Sky Action & Adventure</name> in stead of showing it as it looks in the actual browser dump of <name>Sky Action & Adventure</name> so this is totaly annoying me now here is all of my code with the security stuff removed lol <?php error_reporting(E_ALL); //COUNT FOR CHANNEL NUMBERS $API_COUNT = '0'; $m3u = ""; // GET FUNCTIONS TO GRAB USERNAME / PASSWORD / SERVER $API_USERNAME = $_GET['u']; $API_PASSWORD = $_GET['p']; $API_SERVER = $_GET['s']; // API LOGIN TO GET TOKEN $API_TOKEN = get_url("http://".$API_SERVER."./login.php?username=".$API_USERNAME."&password=".$API_PASSWORD); $data = get_url('http://'.$API_SERVER.'./channels.php?token='.$API_TOKEN); $one = preg_replace("/<name>(.*?) (\((.*?)\))<\/name>/s", "<name>$1</name>", $data); $two = preg_replace("/<plot>(.*?)<\/plot>/s", "<plot>Null</plot>", $one); $API_CHANNELS = simplexml_load_string($two); foreach ($API_CHANNELS as $API_CHANNEL){ $image=$API_CHANNEL->logo; $sd=$API_CHANNEL->url_sd; $hd=$API_CHANNEL->url_hd; $plot=$API_CHANNEL->description; if (strpos($API_CHANNEL->name, '----') !== false) { }else{ $title = $API_CHANNEL->name } $API_COUNT = $API_COUNT + 1; if($hd == ""){ $m3u .= '#EXTINF:-'.$API_COUNT.' tvg-logo="'.$image.'",'.$title." [SD]\r\n"; $m3u .= $API_SERVER."/play.php?id=".$sd."\r\n"; }else{ $m3u .= '#EXTINF:-'.$API_COUNT.' tvg-logo="'.$image.'",'.$title." [SD]\r\n"; $m3u .= $API_SERVER."/play.php?id=".$sd."\r\n"; $m3u .= '#EXTINF:-'.$API_COUNT.' tvg-logo="'.$image.'",'.$title." [HD]\r\n"; $m3u .= $API_SERVER."/play.php?id=".$hd."\r\n"; } } function get_url($url){ //user agent is very necessary, otherwise some websites like google.com wont give zipped content $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-Language: en-US,en;q=0.8rn" . "Accept-Encoding: gzip,deflate" . "Accept-Charset:UTF-8,*;q=0.5rn" . "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.4rn" ) ); $context = stream_context_create($opts); $content = file_get_contents($url ,false,$context); //If http response header mentions that content is gzipped, then uncompress it foreach($http_response_header as $c => $h) { if(stristr($h, 'content-encoding') and stristr($h, 'gzip')) { //Now lets uncompress the compressed data $content = gzinflate( substr($content,10,- ); } } return $content; } header("content-type: audio/x-mpegurl"); header("Content-Disposition: attachment; filename=Playlist.m3u"); ?> #EXTM3U<?php echo " \r\n"?> <?php echo $m3u; ?>
  4. yeh its confusing the hell out of me because if i print data it all shows fine but then simple xml errors out because all <> have been change to there respective html eliments i dont know what todo other than regex it but i would rather not if possible due to the changing nature of the output
  5. quick question for every one here why dose it have to be so complicated ?? use regex to replace } { found after message and before data with , this then takes servers out put of {"CODE":"01","MESSAGE":"Certificate Found"} {"data":[{"lab_id":"9","lab_no":"PPP018","lab_parent":"BVA018","lab_name":"Molanganiii (Pty) Ltd","comp_reg_no":"","lab_description":"CODES OF GOOD PRACTICE","disciplines":"The facility complies with the requirements","phys_1":"Mile Road Park","phys_2":"Ruwanda","phys_city":"Mali","phys_code":"9999","province":"Mule","updated":"2011-01-25 16:01:45"}]} and give you proper functioning json of {"CODE":"01","MESSAGE":"Certificate Found","data":[{"lab_id":"9","lab_no":"PPP018","lab_parent":"BVA018","lab_name":"Molanganiii (Pty) Ltd","comp_reg_no":"","lab_description":"CODES OF GOOD PRACTICE","disciplines":"The facility complies with the requirements","phys_1":"Mile Road Park","phys_2":"Ruwanda","phys_city":"Mali","phys_code":"9999","province":"Mule","updated":"2011-01-25 16:01:45"}]} you should then be able to access data using json decode pritty easy with no errors ? i mean simply doing something like preg_replace("/}[[:space:]]+{/", ",", $input_lines); should work fine and give you valid json to decode
  6. glad it helped if you need any more help feel free to send me a direct message
  7. content is as follows <?xml version="1.0" encoding="UTF-8"?> <channels> <channel> <name>ITV (Now: No Show Namw Found! )</name> <logo>http://www.itv.com/entity/32aa2a6e-046e-4ccd-bb89-9147c581dc43/image.jpg.ashx?q=80&format=jpg&w=1366&h=769</logo> <description>No Show Description!</description> <url_sd>https://itv1liveios-i.akamaihd.net/hls/live/203437/itvlive/ITV1MN/master.m3u8</url_sd> <url_hd>https://itv1liveios-i.akamaihd.net/hls/live/203437/itvlive/ITV1MN/master.m3u8</url_hd> </channel> </channels> there are about 150 diffrent <channel> child eliments but i just left one as an example also it sshould be noted the <url_hd> eliment is not there for all channels just a select few
  8. the incoming xml contains a lot of special chars and is not true formatter xml and is also sent as plain text from a remote server viewing the page source shows an xml structure i have tried doing it with out any encoding or decoding but still the same issuethis is the erro i get SimpleXMLElement::__construct(): <name>5 USA (Now: 22:00 Law & Order: Special Victims Unit)</name> in /home/******/public_html/m3u.php on line 20 my codeto load the remote file is as follows // API LOGIN TO GET TOKEN $API_TOKEN = get_url("http://".$API_SERVER."/login.php?username=".$API_USERNAME."&password=".$API_PASSWORD); $data = get_url('http://'.$API_SERVER.'/livetv/channels.php?&token='.$API_TOKEN); $API_CHANNELS = new SimpleXMLElement($data); foreach ($API_CHANNELS as $API_CHANNEL){ $image=$API_CHANNEL->logo; $sd=$API_CHANNEL->url; $hd=$API_CHANNEL->url_hd; $plot=$API_CHANNEL->description; } function get_url($url) { //user agent is very necessary, otherwise some websites like google.com wont give zipped content $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-Language: en-US,en;q=0.8rn" . "Accept-Encoding: gzip,deflate,sdchrn" . "Accept-Charset:UTF-8,*;q=0.5rn" . "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.4rn" ) ); $context = stream_context_create($opts); $content = file_get_contents($url ,false,$context); //If http response header mentions that content is gzipped, then uncompress it foreach($http_response_header as $c => $h) { if(stristr($h, 'content-encoding') and stristr($h, 'gzip')) { //Now lets uncompress the compressed data $content = gzinflate( substr($content,10,- ); } } return $content; } as you can see i am loading the remote page through a function to grab it properly as it is gzip encoded if you echo out $data all shows fine but the moment simple xml tries to load it < and > all turn to there respective entities
  9. ok i am trying to read an remote xml file from my isp that has some live channels from my tv service i am using php on a local server todo this and output it as an m3u for all my devices i have an issue tho in browser the xml file outputs fine and looks good but the moment i try to load it into simplexml it failes every single time the issue i see is that in the error logs the xml seems to show as if its been html encoded <name> becomes <name> i have tried running html decoding on the string before passing it to simple xml still the same problem tho and i have tried decoding as its passed to xml with $API_CHANNELS = new SimpleXMLElement(html_entity_decode($data)); but again same issue i cant seem to figure out a way to fix it has anyone else ever had this issue
  10. i think what you want todo is really easy and can be done with one simple line of regex preg_replace("/href=\"http:\/\/www.domain.com\/entry.php\/(.*?)\/(.*?)\"/", "href="{EntryNumber=$01.link}"", $input_data); you can see this working at the following link : http://www.phpliveregex.com/p/jGr
×
×
  • 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.