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)

Videx 02-15-2010 10:29 AM

First, you could just disable bitly (change $useBitly= ; to false). In the above code I see the <> signs included in both your keys; they aren't supposed to be.

lhridley 02-15-2010 11:16 AM

ok, I've installed this per the instructions and it's working great for new threads; however, I tried to also install a duplicate using the hook "newreply_post_complete" to get thread replies tweeted as well, and that doesn't seem to be working.

I have a technical forum with a moderate amount of activity, and tweets when threads receive replies are important to my members. Any guidance on modifying this to tweet thread replies would be great!

wolfyman 02-15-2010 11:28 AM

Quote:

Originally Posted by kall (Post 1982202)
This might be a silly question, but.. do you maybe have your URLs set to something other than Standard URLs?

Holy crap someone answered me!!! WOOOT!!!!

;)

Actually, yes I do.

URLs are set to: Basic Friendly URLs

Here is my Twitter plugin code:

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(33,32,6,14);

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

if (!
in_array($foruminfo[forumid], $excludedForums)) {
    
$shortUrl 'http://**********.com/forums/showthread.php?'.$newpost[threadid];

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

    
$tweet '';
    if (isset(
$newpost['prefixid']) && $newpost['prefixid'] != '') {
        
$tweet $vbphrase['prefix_'.$newpost['prefixid'].'_title_plain'].' ';
    }
    
$tweet .= $newpost['title'].' '.$shortUrl;

    
// http://classes.verkoyen.eu/twitter/
    
require_once 'twitter.php';
    
$twitter = new Twitter('***********','*********');
    
$twitter->updateStatus($tweet);



lhridley 02-15-2010 12:16 PM

OK, I was able to answer my own question.

The issue had to do with the context of the tweet; if the tweet appeared to be one that had already been sent through the API, then it did not post, which is why replies to posts weren't showing up when I hooked into newpost_complete.

The solution: add a date/timestamp to the tweet.

I modified the tweet contents to contain:

$tweet .= date("F j, Y, g:i:s a");

as part of the $tweet string, which generates a date/time stamp in the format of Month day, Year hour:min:sec am/pm. This differentiates the tweet context enough so that a new tweet is posted.

Then, attach the plugin to newpost_complete and newthread_post_complete and you get posts for new threads, and replies to new threads.

Cool!

kall 02-15-2010 01:34 PM

Quote:

Originally Posted by wolfyman (Post 1982869)
Holy crap someone answered me!!! WOOOT!!!!

;)

Actually, yes I do.

URLs are set to: Basic Friendly URLs

Here is my Twitter plugin code:

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(33,32,6,14);

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

if (!
in_array($foruminfo[forumid], $excludedForums)) {
    
$shortUrl 'http://**********.com/forums/showthread.php?'.$newpost[threadid];

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

    
$tweet '';
    if (isset(
$newpost['prefixid']) && $newpost['prefixid'] != '') {
        
$tweet $vbphrase['prefix_'.$newpost['prefixid'].'_title_plain'].' ';
    }
    
$tweet .= $newpost['title'].' '.$shortUrl;

    
// http://classes.verkoyen.eu/twitter/
    
require_once 'twitter.php';
    
$twitter = new Twitter('***********','*********');
    
$twitter->updateStatus($tweet);



I'd be quite surprised if this worked with anything other than Standard URLs.

Standard: showthread.php?t=threadid

Friendly: showthread.php?threadttitle

Plugin:
PHP Code:

       $shortUrl 'http://www.yourforumsdomain.com/showthread.php?t='.$newpost[threadid]; 

My guess would be that the URL format has to be set to Standard for this mod to work. You could try changing $newpost[threadid] to $newpost[title], not sure if that will work though. :)

eMike 02-15-2010 01:50 PM

buro9

Fantastic mod, awesome support.
Managed to get it to work just fine by reading through all the posts.

5 stars!

:)

Hateman 02-15-2010 02:06 PM

Hi girls,

i got this error by submitting a thread:

syntax error, unexpected $end .... like the other peoples here. Do you support this mod?

kall 02-15-2010 02:30 PM

Quote:

Originally Posted by Hateman (Post 1982960)
Hi girls,

i got this error by submitting a thread:

syntax error, unexpected $end .... like the other peoples here. Do you support this mod?

Hello Penelope,

What is the content of your plugin?

If you filled it in correctly, that error does not occur.

steeler7 02-15-2010 03:10 PM

2 Things are/aen't happening for me...

1. New threads aren't showing up in Twitter.
2. After I finish typing out a new thread and click "Submit new thread" it submits it but I get a blank screen and need to click the back arrow on my browser and then click on the forum and it shows the Thread that I had made.

Here's my code...

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(1,2,3,35,36,37,38,39,40,43);

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

if (!
in_array($foruminfo[forumid], $excludedForums)) {
    
$shortUrl 'http://www.pittsburghsportstavern.com/forum/showthread.php?t='.$newpost[threadid];

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

    
$tweet '';
    if (isset(
$newpost['prefixid']) && $newpost['prefixid'] != '') {
        
$tweet $vbphrase['prefix_'.$newpost['prefixid'].'_title_plain'].' ';
    }
    
$tweet .= $newpost['title'].' '.$shortUrl;

    
// http://classes.verkoyen.eu/twitter/
    
require_once 'twitter.php';
    
$twitter = new Twitter('pghsportstavern','********');
    
$twitter->updateStatus($tweet);


I put the 2 attached files in my "/forum" folder.

I triple checked my bitly and twitter information and it appears to be correct

kall 02-15-2010 03:13 PM

Does it make it to Twitter?

Have you checked your error_log to see if that sheds light on the white page issue? I'd guess out of memory, but that is a total stab in the dark.


All times are GMT. The time now is 09:32 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.01749 seconds
  • Memory Usage 1,786KB
  • 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
  • (4)bbcode_php_printable
  • (3)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