Mantis Bug Tracker
 

View Issue Details Jump to Notes ] Wiki ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010651mantisbtintegrationpublic2009-06-29 23:252009-12-29 10:06
ReporterEricSWB 
Assigned To 
PrioritynormalSeveritytweakReproducibilitysometimes
StatusfeedbackResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0010651: Twitter Integration not Working.
DescriptionI cannot get the Twitter integration to work.
Steps To ReproduceIn the config_inc.php file, this is what I have at the end before the php end.

   #############################
   # Twitter Settings
   #############################

   # The integration with twitter allows for a Mantis installation to post
   # updates to a twitter account. This feature will be disabled if username
   # is empty or if the curl extension is not enabled.

   # The twitter account user name.
   $g_twitter_username = 'EricSWB';
   
   # The twitter account password.
   $g_twitter_password = 'password';
Additional InformationIn the core/twitter_api.php file, this is what I have:

<?php
# Mantis - a php based bugtracking system

# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net

# Mantis is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Mantis is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mantis. If not, see <http://www.gnu.org/licenses/>. [^]

    # --------------------------------------------------------
    # $Id: twitter_api.php,v 1.4.2.1 2007-10-13 22:35:46 giallu Exp $
    # --------------------------------------------------------

    $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;

    require_once( $t_core_dir . 'config_api.php' );

    $g_twitter_enabled = null;

    # --------------------
    # Checks if twitter is used for the current installation.
    # returns true for enabled, false otherwise.
    function twitter_enabled() {
        global $g_twitter_enabled;

        if ( null === $g_twitter_enabled ) {
            $g_twitter_enabled = !is_blank( config_get( 'EricSWB' ) );
        }
        
        if ( $g_twitter_enabled && !function_exists( 'curl_init' ) ) {
            trigger_error( ERROR_TWITTER_NO_CURL_EXT, ERROR );
        }

        return $g_twitter_enabled;
    }
    
    # --------------------
    # Posts a twitter update when a bug is resolved.
    # @param $p_bug_id The bug id that was resolved.
    function twitter_issue_resolved( $p_bug_id ) {
        if ( !twitter_enabled() ) {
            return true;
        }
        
        $t_bug = bug_get( $p_bug_id, false );

        # Do not twitter except fixed issues
        if ( $t_bug->resolution != FIXED ) {
            return true;
        }

        # Do not twitter private bugs.
        if ( $t_bug->view_state != VS_PUBLIC ) {
            return true;
        }
        
        # Do not twitter bugs belonging to private projects.
        if ( VS_PRIVATE == project_get_field( $t_bug->project_id, 'view_state' ) ) {
            return true;
        }

        $c_bug_id = db_prepare_int( $p_bug_id );

        if ( is_blank( $t_bug->fixed_in_version ) ) {
            $t_message = sprintf(
                            lang_get( 'twitter_resolved_no_version' ),
                            $c_bug_id,
                            $t_bug->category,
                            $t_bug->summary,
                            user_get_name( $t_bug->handler_id ) );
        } else {
            $t_message = sprintf(
                            lang_get( 'twitter_resolved' ),
                            $c_bug_id,
                            $t_bug->category,
                            $t_bug->summary,
                            user_get_name( $t_bug->handler_id ),
                            $t_bug->fixed_in_version );
        }

        return twitter_update( $t_message );
    }
    
    # --------------------
    # Posts a twitter update when a news entry is submitted.
    # @param $p_news_id The newly posted news id.
    function twitter_news( $p_news_id ) {
        if ( !twitter_enabled() ) {
            return true;
        }

        $t_news_view_state = news_get_field( $p_news_id, 'view_state' );
        if ( VS_PUBLIC != $t_news_view_state ) {
            return true;
        }

        $t_news_project_id = news_get_field( $p_news_id, 'project_id' );
        if ( $t_news_project_id != ALL_PROJECTS ) {
            $t_project_view_state = project_get_field( $t_news_project_id, 'view_state' );
            if ( VS_PUBLIC != $t_project_view_state ) {
                return true;
            }
        }

        $t_news_headline = news_get_field( $p_news_id, 'headline' );

        return twitter_update( $t_news_headline );
    }

    # --------------------
    # Posts an update to twitter
    # @param $p_message The message to post.
    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( 'EricSWB' );
        $t_password = config_get( '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 );
    }
?>
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
User avatar (0022324)
vboctor (administrator)
2009-06-30 04:24

What error/behavior are you getting? Do you have the PHP curl extension installed?
User avatar (0022333)
vboctor (administrator)
2009-06-30 12:24

This is a PHP extension rather than a MantisBT plugin. See the following post for details about how to check if it is installed:

http://www.wallpaperama.com/forums/how-to-find-out-if-php-is-compiled-with-curl-extension-installed-enabled-t1576.html [^]
User avatar (0022456)
vboctor (administrator)
2009-07-09 02:21

1. What is the error that you are using?

2. In the API dump that you included, config_get() is attempting to retrieve invalid configuration option names. Is this part of your changes before posting the bug, or is this what you are using?

        $t_username = config_get( 'EricSWB' );
        $t_password = config_get( 'password' );

These calls should look as follows:

        $t_username = config_get( 'twitter_username' );
        $t_password = config_get( 'twitter_password' );

3. Do your server have direct access to the internet? Is there a proxy?

4. What OS / Apache / MantisBT versions are you using?
User avatar (0022513)
EricSWB (reporter)
2009-07-15 22:28

Victor,

Did you ever figure this out?
User avatar (0024006)
piccolobill (reporter)
2009-12-29 10:06
edited on: 2009-12-29 12:08

I have the same problem, but I think it depends of proxy.
How can I configure the apche/php to work behind a proxy?
My proxy have a username/password authentication. But I didn't find nothing to configure apache in this way.
Thanks


- Issue History
Date Modified Username Field Change
2009-06-29 23:25 EricSWB New Issue
2009-06-30 04:24 vboctor Note Added: 0022324
2009-06-30 04:24 vboctor Status new => feedback
2009-06-30 12:24 vboctor Note Added: 0022333
2009-07-09 02:21 vboctor Note Added: 0022456
2009-07-15 22:28 EricSWB Note Added: 0022513
2009-12-29 10:05 piccolobill Issue Monitored: piccolobill
2009-12-29 10:06 piccolobill Note Added: 0024006
2009-12-29 10:54 piccolobill Note Edited: 0024006 View Revisions
2009-12-29 12:08 piccolobill Note Edited: 0024006 View Revisions


MantisBT 1.2.2 git master-1.2.x[^]
Copyright © 2000 - 2010 MantisBT Group
Time: 0.2640 seconds.
memory usage: 2,005 KB
Powered by Mantis Bugtracker