Thread: Miscellaneous Hacks - vBulletin to Twitter, live tweets of new threads
View Single Post
  #232  
Old 02-16-2010, 09:55 AM
lhridley lhridley is offline
 
Join Date: Dec 2009
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, for those who want to post thread replies and new threads to twitter -- I think I figured this out.

1. Use the following to create a string for new threads (modify to suite you, but leave the datestamp portion in) -- keep the rest of the provided plugin code as is:

PHP Code:
$tweet '';
    if (isset(
$newpost['prefixid']) && $newpost['prefixid'] != '') {
        
$tweet .= date("YMj g:i:s a") . ' ' $vbphrase['prefix_'.$newpost['prefixid'].'_title_plain'].' ';
    }
    
$tweet .= date("Ydj g:i:s a") . ' ' .$newpost['title'].' '.$shortUrl;
    
$tweet .= ' new thread #mysearchterm'//replace #mysearchterm with something related to your forum 
2. Hook at newthread_post_complete

3. Use the following plugin code for replies:
PHP Code:
// The array below are the ids of non-public forums, update these to be your admin forum ids or anything non-public by default
$excludedForums = array();

// If you are having trouble getting bitly URL shortening to work... disable it!
$useBitly true;

if (!
in_array($threadinfo[forumid], $excludedForums)) {
    
$shortUrl 'http://www.myforumdomainname.co/showthread.php?t='.$threadinfo[threadid];

    if (
$useBitly) {
      
// http://classes.verkoyen.eu/bitly
      
require_once 'bitly.php';
      
$bitly = new Bitly('mybitlyaccountid''mybitlykey');
      
$shortUrl $bitly->shorten($shortUrl);
    }

    
$tweet '';
    
$tweet .= date("YMj g:i:s a") . ' ' $vbphrase['prefix_'.$threadinfo['prefixid'].'_title_plain'].' ';
    
$tweet .= $threadinfo['title'].' '.$shortUrl;
    
$tweet .= ' new reply #keyword'//again, use a #keyword related to your forum
    // http://classes.verkoyen.eu/twitter/
    
require_once 'twitter.php';
    
$twitter = new Twitter('mytwitteraccount','mypassword');
    
$twitter->updateStatus($tweet);

4. Use the following "two" hooks for the above code snippet:

newreply_post_ajax
newreply_post_complete

It looks like vBulletin triggers one or the other upon posting a new reply, but not both (and, most new posts will go through 'newreply_post_ajax'). vBulletin plugins are a new thing for me -- took a bit to figure this one out.

You can see a working feed at http://www.twitter.com/mediawikiusers
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01232 seconds
  • Memory Usage 1,793KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete