Beispiel #1
0
/**
 * Check if we need to broadcast a notice over the Twitter bridge, and
 * do so if necessary. Will determine whether to do a straight post or
 * a repeat/retweet
 *
 * This function is meant to be called directly from TwitterQueueHandler.
 *
 * @param Notice $notice
 * @return boolean true if complete or successful, false if we should retry
 */
function broadcast_twitter($notice)
{
    $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE);
    // Don't bother with basic auth, since it's no longer allowed
    if (!empty($flink) && TwitterOAuthClient::isPackedToken($flink->credentials)) {
        if (is_twitter_bound($notice, $flink)) {
            if (!empty($notice->repeat_of) && is_twitter_notice($notice->repeat_of)) {
                $retweet = retweet_notice($flink, Notice::staticGet('id', $notice->repeat_of));
                if (is_object($retweet)) {
                    Notice_to_status::saveNew($notice->id, twitter_id($retweet));
                    return true;
                } else {
                    // Our error processing will have decided if we need to requeue
                    // this or can discard safely.
                    return $retweet;
                }
            } else {
                return broadcast_oauth($notice, $flink);
            }
        }
    }
    return true;
}
Beispiel #2
0
function broadcast_twitter($notice)
{
    $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE);
    if (is_twitter_bound($notice, $flink)) {
        if (TwitterOAuthClient::isPackedToken($flink->credentials)) {
            return broadcast_oauth($notice, $flink);
        } else {
            return broadcast_basicauth($notice, $flink);
        }
    }
    return true;
}
Beispiel #3
0
function broadcast_twitter($notice)
{
    $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE);
    // Don't bother with basic auth, since it's no longer allowed
    if (!empty($flink) && TwitterOAuthClient::isPackedToken($flink->credentials)) {
        if (!empty($notice->repeat_of) && is_twitter_notice($notice->repeat_of)) {
            $retweet = retweet_notice($flink, Notice::staticGet('id', $notice->repeat_of));
            if (!empty($retweet)) {
                Notice_to_status::saveNew($notice->id, $retweet->id);
            }
        } else {
            if (is_twitter_bound($notice, $flink)) {
                return broadcast_oauth($notice, $flink);
            }
        }
    }
    return true;
}