Example #1
0
/**
 * Posts an update to twitter
 *
 * @param $p_message  The message to post.
 * @access private
 */
function twitter_update($p_message)
{
    if (!twitter_enabled()) {
        return true;
    }
    if (is_blank($p_message)) {
        return true;
    }
    # don't prepare the string, otherwise it will be escaped twice once by MantisBT and once by Twitter
    $c_message = $p_message;
    // Set username and password
    $t_username = config_get('twitter_username');
    $t_password = config_get('twitter_password');
    // The twitter API address
    $t_url = 'http://twitter.com/statuses/update.xml';
    // Set up and execute the curl process
    $t_curl = curl_init();
    curl_setopt($t_curl, CURLOPT_URL, $t_url);
    curl_setopt($t_curl, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($t_curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($t_curl, CURLOPT_POST, 1);
    curl_setopt($t_curl, CURLOPT_POSTFIELDS, 'status=' . $c_message);
    curl_setopt($t_curl, CURLOPT_USERPWD, $t_username . ':' . $t_password);
    $t_buffer = curl_exec($t_curl);
    curl_close($t_curl);
    return !is_blank($t_buffer);
}
Example #2
0
function twitter_update($p_message)
{
    if (!twitter_enabled()) {
        return true;
    }
    if (is_blank($p_message)) {
        return true;
    }
    $c_message = db_prepare_string($p_message);
    // Set username and password
    $t_username = config_get('twitter_username');
    $t_password = config_get('twitter_password');
    // The twitter API address
    $t_url = 'http://twitter.com/statuses/update.xml';
    // Set up and execute the curl process
    $t_curl = curl_init();
    curl_setopt($t_curl, CURLOPT_URL, $t_url);
    curl_setopt($t_curl, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($t_curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($t_curl, CURLOPT_POST, 1);
    curl_setopt($t_curl, CURLOPT_POSTFIELDS, "status={$c_message}");
    curl_setopt($t_curl, CURLOPT_USERPWD, "{$t_username}:{$t_password}");
    $t_buffer = curl_exec($t_curl);
    curl_close($t_curl);
    return !is_blank($t_buffer);
}