2010-06-23, 04:09 AM
I am trying to create a plugin to tweet new threads to Twitter. I found a tutotial on mybbsource, that did not work: http://mybbsource.com/archive/index.php/...-3745.html
I then found another to tweet calendar events from mybb to Twitter, and that didn't work either: http://valadilene.org/2010/02/09/how-to-...ts-on-mybb
So, I took what was applicable and rewrote it, but I don't quite have it right. I know that it should be simple and there's not much code to it, but I'm just not experienced enough to get the querie right and am not quite sure on how to properly configure the fields to send to Twitter.
I get several errors after activating the plugin and creating a thread, and it does not tweet the thread to Twitter, surprise-surprise.
There are 3 errors displayed after posting a thread, including:
[PHP] error->Handler
inc/class_plugins.php Line 101 call_user_func_array
newthread.php Line 431 Plugin System ->run_hooks
Anyone that can help finish this off is welcome to take credit for it.
I am also using the Google SEO plugin available here.
Here is what I have now:
And I am attaching the Twitter class file I have. I am also using the twitterOAuth library, which is the same library used for the Twitter Login plugin.
I then found another to tweet calendar events from mybb to Twitter, and that didn't work either: http://valadilene.org/2010/02/09/how-to-...ts-on-mybb
So, I took what was applicable and rewrote it, but I don't quite have it right. I know that it should be simple and there's not much code to it, but I'm just not experienced enough to get the querie right and am not quite sure on how to properly configure the fields to send to Twitter.
I get several errors after activating the plugin and creating a thread, and it does not tweet the thread to Twitter, surprise-surprise.
There are 3 errors displayed after posting a thread, including:
[PHP] error->Handler
inc/class_plugins.php Line 101 call_user_func_array
newthread.php Line 431 Plugin System ->run_hooks
Anyone that can help finish this off is welcome to take credit for it.
I am also using the Google SEO plugin available here.
Here is what I have now:
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("newthread_do_newthread_end", "twitterfeed");
function testplugin_info()
{
return array(
"name" => "Twitterfeed",
"description" => "Tweed new threads to Twitter!",
"website" => "",
"author" => "",
"authorsite" => "",
"version" => "1.1",
"guid" => "",
"compatibility" => "1*",
);
}
function twitterfeed_activate()
{
}
function twitterfeed_deactivate()
{
}
function twitterfeed_addthread()
{
global $details, $mybb, $db;
// gets thread data from the db
$q=$db->simple_select('threads','username, subject, dateline, fid, tid',array('limit'=>1));
$thread=$db->fetch_array($q);
// include twitter class
require_once('class.twitter.php');
require_once('twitterOAuth/twitterOAuth.php');
require_once('twitterOAuth/OAuth.php');
// get URL
$url($mybb->settings['bburl']."/newthread.php?action=fid");
// send twitter status
$tw=new twitter();
$tw->username=myusername;
$tw->password=mypassword;
$tw->update("[".my_date('d M',$thread['subject'])."] {$thread['username']} {$url}");
}
?>
And I am attaching the Twitter class file I have. I am also using the twitterOAuth library, which is the same library used for the Twitter Login plugin.