#1  
Old 8th September 2009, 03:05
kentor kentor is offline
Member
 
Join Date: Apr 2009
Posts: 32
Default channel api and utf 8

So I'm trying to load the channel XML file with php using
Code:
<?php
$doc = new DOMDocument();
$xml = "http://channel.api.livestream.com/1.0/info?channel=oystein123"
$doc->load($xml);
?>
And I get the error:
Code:
Warning: DOMDocument::load() [domdocument.load]: Input is not proper UTF-8, indicate encoding ! Bytes: 0xD8 0x79 0x73 0x74 in http://channel.api.livestream.com/1.0/info?channel=oystein123
i noticed this happens to any channel whose title has some special character in it.
is there a fix to this?

Last edited by kentor; 8th September 2009 at 03:08.
Reply With Quote
  #2  
Old 8th September 2009, 09:25
FVMK FVMK is offline
Junior Member
 
Join Date: Aug 2008
Posts: 22
Default

Tested this, should work:
<?php

$myXMLString = file_get_contents("http://channel.api.livestream.com/1.0/info?channel=oystein123");
$myXMLString = utf8_decode($myXMLString);
$doc = new DOMDocument('1.0', 'iso-8859-1');
$doc->loadXML($myXMLString);

echo $doc->saveHTML();

?>
Reply With Quote
  #3  
Old 10th September 2009, 21:57
kentor kentor is offline
Member
 
Join Date: Apr 2009
Posts: 32
Default

it doesn't give an error anymore but the special characters are just replaced by a "?".

plus I think this method is kind of slow and it uses a lot more resources especially if you want to do this for lots of channels

thanks for the help though

Last edited by kentor; 10th September 2009 at 22:00.
Reply With Quote
  #4  
Old 11th September 2009, 10:16
paul167 paul167 is offline
Livestream Software Engineer
 
Join Date: Sep 2008
Posts: 190
Default

Thanks for reporting this, we're going to take a look at it and will let you know.
Reply With Quote
  #5  
Old 12th September 2009, 05:58
FVMK FVMK is offline
Junior Member
 
Join Date: Aug 2008
Posts: 22
Default

This works fine for me:

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Livestream Channel-API Test</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
        <div>
            <?php
                $myXMLString 
file_get_contents("http://channel.api.livestream.com/1.0/info?channel=oystein123");
                
$myXMLString utf8_encode($myXMLString);
                
$doc = new DOMDocument('1.0''UTF-8');
                
$doc->loadXML($myXMLString);
                
//echo $doc->getElementsByTagName('channel')->item(0)->getElementsByTagName('isLive')->item(0)->nodeValue;
                
echo $doc->saveHTML();
            
?>
        </div>
    </body>
</html>
Reply With Quote
Reply

Tags
api, channel, encoding, error, utf-8

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump