vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Miscellaneous Hacks - vBulletin to Twitter, live tweets of new threads (https://vborg.vbsupport.ru/showthread.php?t=234288)

lhridley 02-16-2010 09:55 AM

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

tokenyank 02-16-2010 05:06 PM

installed and working!

http://www.twitter.com/mumsonline

Thanks!

lazydesis 02-16-2010 06:50 PM

works perfectly in vb3.8 ...thanks for this

mtlcore 02-17-2010 04:56 AM

Great mod! Really worth it if someone teamed up with you to develop it into a full product.
I am getting this error though:

Quote:

Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in [path]/twitter.php on line 189
/statuses/update.xml Could not authenticate you.
Fatal error: Uncaught exception 'TwitterException' with message 'Unauthorized' in /home/mysite/public_html/forums/twitter.php:229 Stack trace: #0 /home/mysite/public_html/forums/twitter.php(648): Twitter->doCall('statuses/update...', Array, true) #1 /home/mysite/public_html/forums/newthread.php(273) : eval()'d code(26): Twitter->updateStatus('testing http://...') #2 /home/mysite/public_html/forums/newthread.php(273): eval() #3 /home/mysite/public_html/forums/vbseo.php(1129): require('/home/mysite/p...') #4 {main} thrown in /home/mysite/public_html/forums/twitter.php on line 229
I have curl enabled, safe_mode is off, open_basedir has a local value:

Quote:

home/mysite:/usr/lib/php:/usr/local/lib/php:/tmp
and no value under master value.

I've checked all the code in the plugin, all exactly the same as yours (with my info ofcourse).

bit.ly seems to be working fine since new URLs are being created, just not being posted to Twitter...

EDIT
I got it to work! BUT no bit.ly URL :(
Here what I did, I went into twitter.php and set the following to false.
$options[CURLOPT_FOLLOWLOCATION] = false;

now to solve the bit.ly issue.

Thanks

hiker 02-17-2010 02:18 PM

Could I use this with multiple twitter accounts?

For example, I've got a hiking forum that I'd like to go to a hiking related twitter account, then I've got a mountain biking forum (same board) that I'd like to go to a different mountain biking related twitter account.

Is this possible?

Thanks, great mod regardless.

whelck 02-17-2010 08:55 PM

After reading the entire thread, I have wonderfully concluded my error message is different from any other!


Expectation Failed on line 229 in /var/www/ufck/forums/twitter.php
#0 /var/www/ufck/forums/twitter.php(648): Twitter->doCall('statuses/update...', Array, true)
#1 /var/www/ufck/forums/newthread.php(262) : eval()'d code(26): Twitter->updateStatus('test http://bit...')
#2 /var/www/ufck/forums/newthread.php(262): eval()
#3 {main}


What is broken?

Pro-eSports.com 02-17-2010 09:32 PM

Can you select the forums you want to be tweeted? if not then this would be a great addition for future updates.

whelck 02-17-2010 09:39 PM

Quote:

Originally Posted by Pro-eSports.com (Post 1985043)
Can you select the forums you want to be tweeted? if not then this would be a great addition for future updates.

You can select which forums you *don't* want tweeted, so you end up accomplishing the same thing.

Pro-eSports.com 02-17-2010 09:49 PM

Awesome, I'm gonna install this great mod then. :D

lhridley 02-18-2010 02:16 AM

Quote:

Originally Posted by bogley (Post 1984654)
Could I use this with multiple twitter accounts?

For example, I've got a hiking forum that I'd like to go to a hiking related twitter account, then I've got a mountain biking forum (same board) that I'd like to go to a different mountain biking related twitter account.

Is this possible?

Thanks, great mod regardless.

Yes, with some modifications. Contact me at webmaster@mwusers.com for more info.


All times are GMT. The time now is 08:12 AM.

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.01624 seconds
  • Memory Usage 1,763KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete