Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Digg API to RSS 2.0 Proxy Details »»
Digg API to RSS 2.0 Proxy
Version: 1.00, by Zate Zate is offline
Developer Last Online: Dec 2011 Show Printable Version Email this Page

Category: Add-On Releases - Version: 3.6.8 Rating:
Released: 08-07-2007 Last Update: 08-07-2007 Installs: 8
Additional Files Is in Beta Stage  
No support by the author.

I created this to use with the RSS Features in vBulletin. It uses the DiggAPI to connect to Digg and returns data as a RSS 2.0 feed. You can then use that in the RSS feeds in vbulletin to be posted in what ever forum you like.

Why did I not use the regular Digg RSS feeds? Mainly because you get more control this way, and because those feeds link to Digg, not the article submitted.

So how does it work?

Just copy the code below into a php file (I call mine digg.php).

It takes several arguments.
  • container= and topic= allow you to get the data from any of the containers and topics on digg. You can find a list of what exactly they are here. The container shortname and topic shortname are what you use. Dont use both, use container OR topic.
  • status= allows you to choose between getting upcoming, or popular stories. Default is popular.
  • count= this tells the script how many article to return, default is 10 maximum is 100.
  • sort= - this sorts the resules and can be 1 of 4 entries. More info here (all the way to the bottom)

so, an example? http://www.mydomain.com/digg.php?container=gaming will return the latest popular 10 in the gaming container.

Customisations:

Inside the code, there is user_agent and AKEY that will need to be changed.

user_agent should be Your-Site/1.0 (it just identifies your request)

AKEY is your appkey and needs to be in the form of http%3A%2F%2Fwww.yoursite.com

So here is the code, be nice if your gonna critique it, I just threw it together to scratch and itch. I plan to do it as a plugin eventually and allow tweaking all the options through the adminCP and have it post the responses itself, instead of using the vbulletin RSS system. This will allow using of more elements of the diggapi instead of just what the item tag in RSS 2.0 lets me use.

Demo
Demo2 (Upcoming 20 Articles in Gaming sorted by submit date from latest)

Code:
<?php
ini_set("user_agent", "Change-Me/1.0");
define("AKEY", "http%3A%2F%2Fwww.CHANGEME.com");
$url = "http://services.digg.com/stories?appkey=".AKEY; //this url works

if ($_GET['container']) {
        $url = "http://services.digg.com/stories/container/". htmlentities($_GET['container'])."/";
        if ($_GET['status']) {
                $status = $_GET['status'];
                switch($status) {
                        case 'upcoming' :
                                $url .= "upcoming";
                        break;
                }
        } else { $url .= "popular"; }
        $url .= "?appkey=".AKEY;
        if ($_GET['num']) {
                $url .= "&count=".htmlentities($_GET['num']);
        }
        if ($_GET['sort']) {
                $sort = htmlentities($_GET['sort']);
                switch($sort) {
                        case 'promote_date-desc':
                                $url .= "&sort=".$sort;
                        break;
                        case 'promote_date-asc':
                                $url .= "&sort=".$sort;
                        break;
                        case 'submit_date-desc':
                                $url .= "&sort=".$sort;
                        break;
                        case 'submit_date-asc':
                                $url .= "&sort=".$sort;
                        break;
                }
        }
}

if ($_GET['topic']) {
        $url = "http://services.digg.com/stories/topic/". htmlentities($_GET['topic'])."/";
        if ($_GET['status']) {
                $status = $_GET['status'];
$status = $_GET['status'];
                switch($status) {
                        case 'upcoming' :
                                $url .= "upcoming";
                        break;
                }
        } else { $url .= "popular"; }
        $url .= "?appkey=".AKEY;
        if ($_GET['num']) {
                $url .= "&count=".htmlentities($_GET['num']);
        }
        if ($_GET['sort']) {
                $sort = htmlentities($_GET['sort']);
                switch($sort) {
                        case 'promote_date-desc':
                                $url .= "&sort=".$sort;
                        break;
                        case 'promote_date-asc':
                                $url .= "&sort=".$sort;
                        break;
                        case 'submit_date-desc':
                                $url .= "&sort=".$sort;
                        break;
                        case 'submit_date-asc':
                                $url .= "&sort=".$sort;
                        break;
                }
        }
}

$data = open_url($url);
$diggData = new SimpleXMLElement($data);
$html = '<?xml version="1.0" encoding="windows-1252" ?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
        <channel>
                <title>Digg Proxy Feed</title>
                <link>http://www.tampagamers.com/digg.php</link>
                <description>Latest Articles - '.xmlencode($url).'</description>
';
foreach ($diggData->story as $story) {
$desc = $story->description;
$author = $story->user['name'];
$html .= '<item>
                                <title>'.xmlencode($story->title).'</title>
                                <link>'.xmlencode($story["link"]).'</link>
                                <description>'.xmlencode($desc).'</description>
                                <guid>'.xmlencode($story["link"]).'</guid>
                                <category>'.xmlencode($story->container["name"]).' - '.xmlencode($story->topic["name"]).'</category>
                                <dc:creator>'.xmlencode($author).'</dc:creator>
                        </item>
                        ';
}
$html .= '
        </channel>
</rss>';

header("Content-Type: application/rss+xml");
echo $html;

function changeencoding (&$item1, $key) {
    $item1 = "&#".Ord($key).";";
}

function xmlencode ($s) {
    if (empty($xmltrans)) { // do this only once
        $xmltrans = get_html_translation_table(HTML_ENTITIES);
        array_walk ($xmltrans, 'changeencoding');
        reset ($xmltrans);
    }
    return strtr($s, $xmltrans);
}

function open_url($url) {
        global $data;
        $stream = @fopen($url, 'r');
        if (!$stream) { die("There was a problem connecting to Digg.com with $url"); }
                while (!feof($stream)) {
$data .= fgets($stream);
                }
        fclose($stream);
        return $data;
}

?>
And please, if you have a way of doing something better then let me know. Feel free to use this code as you like, give me credit, or not doesn't matter.

Supporters / CoAuthors

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-08-2007, 01:55 AM
RvG2 RvG2 is offline
 
Join Date: Jan 2007
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is there any demo how does it works?
Reply With Quote
  #3  
Old 08-08-2007, 10:36 AM
Zate Zate is offline
 
Join Date: Apr 2003
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sure, I just added 2 Demo's. Please dont link to them with your live site, they are for demo purposes only.
Reply With Quote
  #4  
Old 08-08-2007, 11:13 AM
projectego's Avatar
projectego projectego is offline
 
Join Date: Feb 2006
Location: UK
Posts: 724
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sounds pretty cool. I might check this out. Thanks for sharing.
Reply With Quote
  #5  
Old 08-14-2007, 04:22 PM
Zate Zate is offline
 
Join Date: Apr 2003
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you can see this in action actually on tampagamers.com where I have it posting digg articles through vbulletins RSS system into several diff forums as different users.
Reply With Quote
  #6  
Old 12-31-2007, 04:02 AM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

very cool mod, wish I saw it earlier.
Reply With Quote
Reply


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


All times are GMT. The time now is 09:18 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04006 seconds
  • Memory Usage 2,267KB
  • Queries Executed 22 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete