RSS Dashboard

pritaeas 1 Tallied Votes 464 Views Share

Attached is the code for my RSS dashboard, using the DaniWeb API. It's an improved version of the mashup I posted earlier, using jQuery to get all feeds asynchronously. The part which initially loads the forums is shown below.

It creates an API object, and a Parser object. The first gets the forums list in JSON format, the second the extracts all forums to create the initial empty div's. A static method to a decorator function is passed, which adds the actual markup. The Parser and Decorator classes are in the zip file, so I won't discuss those here.

If you want to see the result, go here.

Any question, remarks, etc. are welcome.

For some reason I'm not seeing my attached file, you can download the zip file.

diafol commented: another hit! +14
<?php
include '../Classes/DwApi/DwApiCredentials.class.php';
include '../Classes/DwApi/DwApiOAuth.class.php';

include 'Decorator.class.php';
include 'Parser.class.php';

$dwapi = new DwApiOAuth(null);
$parser = new Parser();

$divs = array ();
$forums = $dwapi->GetForums();
if ($forums)
{
    $forums = json_decode($forums);
    foreach ($forums->data as $mainForum)
    {
        $divs = array_merge($divs, $parser->ParseForumsResult($mainForum, array ('Decorator' , 'DivWithTitle')));
    }
}
?>
Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member

Wow sooooo much faster than before!

Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member

For some reason I'm not seeing my attached file, you can download the zip file.

Yeah, I'll fix that. Currently editorial articles don't show their attachments.

Member Avatar for diafol
diafol

Very good. The simplicity of the board makes it accessible on all devices too I would imagine. No need for responsive design :) And you really show off the advantages of the asynchronous nature of ajax - synchronous load must be frightening.

Big like.

pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster

Thanks. Yes, that page loads fine on my Torch. That's the reason I like a width of 300px. Most smaller mobile browser with a width of 320/360 will show it just fine. The only thing I can think of at this moment is to add deferred loading, so that AJAX starts only for those blocks in view. Perhaps I will, maybe...

The previous mashup did it all PHP side, and I tried synchronous while debugging, not recommended.

Dani, the RSS for the assembly forum is still giving issues. It doesn't like the CDATA part (can give issues). Perhaps you fixed this, but I encountered HTL in some descriptions (even entity encoded) that can give issues.

Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member

Yeah I can't figure out which characters it doesn't like. Sorry :(

Can you??

pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster

This is the feed result in Opera:

XML parsing failed

XML parsing failed: syntax error (Line: 1892, Character: 156)

Reparse document as HTML
Error:
invalid character 
Specification:
http://www.w3.org/TR/REC-xml/#NT-Char 
1889:           <title>Does everyone know this code?</title>
1890:           <link>http://www.daniweb.com/software-development/assembly/threads/445396/does-everyone-know-this-code</link>
1891:           <pubDate>Mon, 14 Jan 2013 12:33:58 +0000</pubDate>
1892:           <description>I would like to know about the following code, could anyone tell me, please? .text:004027A0 sub_4027A0 proc near ; CODE XREF: sub_401010+118\18p .text:004027A0 .text:004027A0 var_404 = byte ptr -404h .text:004027A0 .text:004027A0 sub esp, 404h .text:004027A6 lea eax, [esp+404h+var_404] .text:004027A9 push 1 .text:004027AB push eax .text:004027AC call sub_401CC0 .text:004027B1 add esp, ...</description>
1893:           <content:encoded><![CDATA[ <p>I would like to know about the following code, could anyone tell me, please?</p>
1894: 
1895: <pre><code>.text:004027A0 sub_4027A0      proc near               ; CODE XREF: sub_401010+118p

It highlights the \18 in CODE XREF:. So it must be trying to parse it as a unicode character. Oh, it's an "up arrow" character (should have been converted to &uarr;), lemme see if I can remove it.

pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster

Am getting the right feed now.

Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member

Yeah, I didn't fix it yet. It just expired out of the RSS feed. I'll fix it soon.

pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster

If anybody's interested, I just put the code for the RSS dashboard up on GitHub in the Demos folder. It requires the classes, so download everything if you want to test it. Make sure you insert your own API ID and secret in the DwApiAuthorize file. The code uses namespaces so PHP 5.3.0+ is required.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.