Project

General

Profile

Create issues from php application

Added by paul B almost 15 years ago

hope someone can help with this, apologies if it's been asked before. Basically I'm trying to integrate redmine as a backend to our current in-house management system. one of the things I'd like to do is auto-create issues in redmine from a PHP page. So far I've been trying to utilise the 'mail_handler' functionality of redmine to do this, by POSTing data from php straight to the mail handler script.

Here's what I've got so far, but it doesn't work (I just get a blank page, no issue is created). Hope there's a PHP / Redmine expert here who can help!

$category = "enhancement";
$priority = "Low Priority";

$email = 'MIME-Version: 1.0 \n
Content-Type: text/html; charset="US-ASCII" \n
Content-Transfer-Encoding: quoted-printable \n
Content-class: urn:content-classes:message \n
Subject: test issue \n
Date: Mon, 1 Jun 2009 09:31:53 +0100 \n
From: "MY EMAIL" <MYEMAIL@MYCOMPANY.com> \n
\n\n
test message';

    $issue = array("PROJECT"=>$cfg->redmine_project,"TRACKER"=>$cfg->redmine_tracker,"CATEGORY"=>$category,"PRIORITY"=>$priority);
    $data = array("key"=>$cfg->redmine_key,"email"=>$email,"allow_override"=>"CATEGORY,PRIORITY","issue"=>$issue);
    $curl_session = curl_init($cfg->redmine_url."/mail_handler");
        curl_setopt ($curl_session, CURLOPT_POST, 1); 
    curl_setopt ($curl_session, CURLOPT_POSTFIELDS, $data);
     curl_setopt ($curl_session, CURLOPT_FOLLOWLOCATION, 1);
     curl_exec ($curl_session);
     curl_close ($curl_session);

Replies (3)

RE: Create issues from php application - Added by Joe Clarke almost 15 years ago

If php and redmine are on the same server you could make a call out to the command line and use the following Redmine command line interface:

http://github.com/textgoeshere/redcmd/tree/master

RE: Create issues from php application - Added by Eric Davis almost 15 years ago

Paul B:

(I wrapped your code block in pre tags instead of @ so it's easier to read.)

The MailHandlerController will not render anything, you need to check the HTTP status code to see the status.

Eric

RE: Create issues from php application - Added by paul B almost 15 years ago

Php and redmine are on seperate servers (the PHP application is running on a windows server, redmine is on it's own VM)

The problem isn't that nothing's being rendered, it's that the issue isn't being created. Is there anywhere I can look in the logs to see detailed information about what mailHandlerController is expecting and what it's getting?

    (1-3/3)