user1530205
user1530205

Reputation: 302

Incorrect characters returned RSS/XML Feed

hoping someone out there can help. I have a small script using Curl to download a file from an rss feed.

The RSS feed validates as XML yet when I try to run my script I get the following:

‹íYsã6¶Çßó)x=5yá%Œ•=n§¸¦“^’j;=wª+´DKLK¤Š¤Ýíùôà"Ñk@™ÞªÔÕ•¸eŠàøƒƒ…‡?}_.Œ‹¤(Ó<{³‡Ü3’l’OÓlöfï“È{?ýpX”åæ*¬®’ßËʃ*/Š$«ÞìíïË*®Ò   ˜äËýú·û ý=ùíÉ<βdqôƒ!ÿViµHŽª£ýri|:>6Î’djXÆ»t"oTž´¿:Üo®n¾¹H³¯GóªZ(s˜û‡ûõ‡Íï§I9)ÒU%Kyëý÷ûW4ßI«dÙüØ+ܯñ2) ?/¦If`ˆl2aãCšM/w±´93Þ'Ÿïئ–ÿé·ßÞIªêâÏu‰7÷œÄU2Ë‹Ë£“χûë´¿?ŒÏ«y^\«Öy™ûê~²‚íëÛÝòþRåµ&uy-U^2ak©Êk}­ËkͧՅwRäù×ÒR÷·*„™C¨#À¼Z.ú³66;O§g¬¾ûÆØêü4ç(*Òÿ51>Ä—ÍÓGΘ&”÷»{º5ZLò¬’ÿŸd³j~D)ÇCˆIUn½àæ Òì,—ó#¢ àÄЇԣØó˜ís98Œ    
8Èu< Ø»õú«7ﺌgYRýñé—£Ãÿùâî‰û¥ùèà§ïÕ›ó";8­Òù®Í§Ù›Z³‘ÁTOÉ„ÌDجe0L%ƒ©d0L%ÃUñæ|ºú'qÿ‰#ù·*âÉפò©.ÒÉi¥z°üXöÙü<›$×/Ÿ-ò®gÕ7ù±íØÎ=×w·ÏWIvšVíwk#ÄPó›õÏòÇb&á½ïýùçÑF…Í£¾)C)!PÁÍÅÍ7
/\%vý›n^(¡˜ž¥Éôm®]vóò³t‘|”ÂÕêF= Ô„A­hÔJ= Ôz@©Ú{mì­oº±'¾ÈËó"1΋ś=ÕKÙƒå
7&ñdžù„º¯ïë6ºÎðO5àÞ|ipðçö5Ù3u/|³·î§{Fu¹JÞìÅ«•lŠ±âôþwkÓjöŒý–ÛûpßÎp?.Ê<3‚xqÙG¸›e

I've tested it with other XML links and it seems to work. The url is 'HTTPS' if that might make any difference and here is my code:

$url = "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);         
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POST, 1);          
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

$result = curl_exec($ch);
curl_close($ch);

echo $result;

Any help is greatly appreciated

Upvotes: 1

Views: 43

Answers (1)

Pedro Lobito
Pedro Lobito

Reputation: 98921

The output seems to be gzip encoded, try using:

curl_setopt($ch, CURLOPT_ENCODING , "gzip");  

Note:

This option sets the Accept-Encoding: gzip header on the request and uncompresses the response.

Upvotes: 1

Related Questions