I tried this with my 4.2.0-board. It didn't work, the bit.ly-thing threw out errors. After fixing that the twitter-thing threw out other and more complicated errors. I tried to fix it and I got it working. But many changes were needed. I try to tell you:
At first, don't use the attached bitly.php. Use the linked one in the first posting. Or take this link:
http://classes.verkoyen.eu/bitly
unzip it, place it in the forum-root
Second: the twitter-API only accepts oAuth now, no basic username/password authentication anymore. So you have to use the new twitter.php. Don't use the one attached to the first posting. And don't use the one linked in the first posting. Use this one instead:
http://classes.verkoyen.eu/twitter_oauth
unzip it. Don't place it in the forum root now! We have to edit it!
Now you have to get a legacy-API-key from bit.ly:
https://bitly.com/a/settings/advanced
And you need oAuth-data from twitter. Use this link:
https://dev.twitter.com/ then click on "my applications" in the menu on the upper right. Click on "create new application" and enter your data. (you don't need to enter a callback-url) Then your app is created. Click on "settings" and then switch to "Read, Write and Access direct messages". Update application settings. Go back on the "details"-tab and click on "create my access-token". Go to tab "oAuth tool" You will see four keys now. You need all of them. Open your twitter.php, search for "private $oAuthToken = ' ';" Place the "Access token" here. Then search for "private $oAuthTokenSecret = ' ';" Place your "Aceess token secret" between the ' ' here. Now save the file and upload it to your forum root. The other two codes (consumer key, consumer secret) are needed in the plugin-script, see below.
Go to plugin-manager and create a new plugin:
vBulletin
newthread_post_complete
Tweet to Twitter
Now use the following code
If you want to exclude some forums, edit this line:
$excludedForums = array(1, 2);
and place the forum-ids between the brackets. use array() if you don't want to exclude any forums.
this line:
$shortUrl = 'http://yourURLhere.com/showthread.php?t='.$newpost[threadid];
change "YourURLhere.com" to your forum-URL.
In this line:
$bitly = new Bitly('username', 'API_key');
you have to put in your bit.ly-username and the generated API-key.
And in this line:
$twitter = new Twitter('consumer-key','consumer-secret');
you have to put in the consumer-key and the consumer-secret from the twitter o-auth-tool.
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);
// If you are having trouble getting bitly URL shortening to work... disable it!
$useBitly = true;
if (!in_array($foruminfo[forumid], $excludedForums)) {
$shortUrl = 'http://yourURLhere.com/showthread.php?t='.$newpost[threadid];
if ($useBitly) {
// http://classes.verkoyen.eu/bitly
require_once 'bitly.php';
$bitly = new Bitly('username', 'API_key');
$result_bit = array();
$result_bit = $bitly->shorten($shortUrl);
$shortUrl = $result_bit['url'];
}
$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('consumer-key','consumer-secret');
$twitter->statusesUpdate($tweet);
}
Save and activate it. This worked for me :-) No curl-erros anymore, no "unauthorized access" errors anymore, no .... errors, just working