So I traced the execution flow with Komodo and it turned out that in
mybbpublisher_tw_post_update(), after
$tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array('status' => $message)); there was no check for an error. I'm not sure how that happened, since this is where Twitter posting errors (e.g. authentication) would be caught. Anyway, would be great to have an update after you put this check in.
The
if($tmhOAuth->response['code'] == 200) should have an "else" branch, which should essentially dump $tmhOAuth->response['response'] into mybbpublisher_errors_tw. In my case, doing that revealed that the error was "Read-only application cannot POST".
Why that happened is a bit odd:
In OAuth settings, "Access level" was set to "Read and write" (BTW, this should be documented in the README as well, because by default the Access level is Read-only, IIRC).
But in the "Your access token" section, "Access level" was Read-only, and there was no obvious way in the Twitter UI to change it. I clicked "Recreate my access token" twice, and that created a new token (had to copy it into the plugin settings), with "Read and write" access. Odd how that worked, but now the plugin posts to Twitter correctly.
Another thing: usually plugins add their settings in ACP after the last plugin. This reflects the fact that the last installed plugin will have the settings listed last. It would be nice if MybbPublisher did that too in _install():
$result = $db->simple_select('settinggroups', 'MAX(disporder) AS max_disporder');
$max_disporder = $db->fetch_field($result, 'max_disporder');
$settings_group = array(
"gid" => "",
"name" => "MyBBpublisher",
"title" => "MyBBpublisher",
"description" => "Settings for the MyBBpublisher feature.",
"disporder" => $max_disporder +1, // instead of 50
"isdefault" => "0",
);
Another one: the comment "//get initial status update" looks mis-matched. The code there tests if the message is an announcement, or a new thread.
Another one: $l['mybbpublisher_new_thread_tw'] = "{msg} {urlbit}"; suggests that that's the format of the Tweet. However, the code inserts $l['mybbpublisher_at'] into the message by replacing {urlbit} with the actual URL, preceded by the $l['mybbpublisher_at'] string. Would it be clearer if the Twitter message were simply $l['mybbpublisher_new_thread_tw'] = "{msg} at {urlbit}."; (same for announcements) and then users could easily format it in ways that would not include the "at" string? For instance,
my forum tweets like this:
Quote:New thread on #quantifiedself forum: The Quantified Self Forum now posts new threads to Twitter - http://bit.ly/q2bkpk
IMO, format specifiers should replace variables verbatim, and not introduce extra text. What I mean is that {urlbit} should be replaced with just the URL, no "at" string prefix, and no "." suffix. This also helps with localization in Eastern languages - in proper Chinese, the period needs to be replaced with IDEOGRAPHIC FULL STOP (U+3002).