Torch XML API

Using our API, you can interact with Torch programmatically. Torch’s API is an XML based conversion between the programs. Every request you send will be in XML, every response will be in XML.

Every request will require you to send basic HTTP authentication. This info is simply the email and password of one of the internal users.

Connecting to Torch’s API:

The simplest command you can send is an empty request xml document. As long as you properly authenticate this will result in a XML document containing a list of all projects. In these examples, we are sending to the CreativeArc account, you will have to substitute your own account url.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request/>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$post = $rxe->asXML();



$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <project token="TOKEN" key="18" archive="false" >Newsletter Graphics</project>
    <project token="TOKEN" key="13" archive="false" >WebSite Design</project>
</response>

Listing Categories:

For most requests (besides the project list above and inserting projects) you must include a node indicating the project. In this case we’re going to select the project then ask for a list of categories.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <list>categories</list>
</request>  

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');
$list = $rxe->addChild('list', 'categories');
$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <list>
        <category>Graphics</category>
        <category>Code Files</category>
    </list>
</response>

Listing Time:

You can also get a list of time on the selected project.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <list>time</list>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');
$list = $rxe->addChild('list', 'time');
$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <list>
        <time>
            <key>13</key>
            <timestamp>2008-06-16 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>Designed Front Page</note>
            <category>Graphics</category>
            <invoicename>1003</invoicename>
            <user>Ben Smith</user>
            <billrate>100.000000</billrate>
            <cost>100.000000000000</cost>
        </time>
        <time>
            <key>14</key>
            <timestamp>2008-06-16 00:00:00</timestamp>
            <hours>0.500000</hours>
            <note>Sub Page One</note>
            <category>Graphics</category>
            <invoicename>1003</invoicename>
            <user>Ben Smith</user>
            <billrate>100.000000</billrate>
            <cost>50.000000000000</cost>
        </time>
        <time>
            <key>15</key>
            <timestamp>2008-06-16 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>Talked to John on Phone</note>
            <category>Graphics</category>
            <invoicename>1003</invoicename>
            <user>Ben Smith</user>
            <billrate>100.000000</billrate>
            <cost>100.000000000000</cost>
        </time>
        <time>
            <key>86</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>Some Graphics work in August</note>
            <category>Graphics</category>
            <invoicename>1003</invoicename>
            <user>Ben Smith</user>
            <billrate>100.000000</billrate>
            <cost>100.000000000000</cost>
        </time>
        <time>
            <key>87</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>2.000000</hours>
            <note>Meeting with John</note>
            <category>Graphics</category>
            <invoicename>1003</invoicename>
            <user>Ben Smith</user>
            <billrate>100.000000</billrate>
            <cost>200.000000000000</cost>
        </time>
        <time>
            <key>88</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>Write some code for John</note>
            <category>Code Files</category>
            <invoicename>1001</invoicename>
            <user>Ben Smith</user>
            <billrate>100.000000</billrate>
            <cost>100.000000000000</cost>
        </time>
        <time>
            <key>89</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>0.500000</hours>
            <note>Review Code with John</note>
            <category>Code Files</category>
            <invoicename>1001</invoicename>
            <user>Ben Smith</user>
            <billrate>100.000000</billrate>
            <cost>40.000000000000</cost>
        </time>
        <time>
            <key>90</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>More Code Work after first Invoice</note>
            <category>Code Files</category>
            <invoicename>1002</invoicename>
            <user>Ben Smith</user>
            <billrate>100.000000</billrate>
            <cost>100.000000000000</cost>
        </time>
    </list>
</response>

Listing Expenses:

You can also get a list of expenses on the selected project.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <list>expenses</list>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');
$list = $rxe->addChild('list', 'expenses');
$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <list>
        <expense>
            <key>13</key>
            <timestamp>2008-06-16 00:00:00</timestamp>
            <price>50.000000</price>
            <note>Kit</note>
            <category>Graphics</category>
            <invoicename/>
            <user>Ben Smith</user>
            <cost>50.000000</cost>
        </expense>
    </list>
</response>

Listing Payments:

You can also get a list of payments on the selected project.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <list>payments</list>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');
$list = $rxe->addChild('list', 'payments');
$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <list>
        <payment>
            <key>13</key>
            <timestamp>2010-07-16 00:00:00</timestamp>
            <amount>2050.000000</price>
            <note>Payment by Check</note>
            <invoicename>WebDesign Services</invoicename>
        </payment>
    </list>
</response>

Listing Google Docs:

You can also get a list of Google Docs on the selected project.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <list>docs</list>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');
$list = $rxe->addChild('list', 'docs');
$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <list>
        <doc>
            <url>http://docs.google.com/a/wbpsystems.com/Doc?id=dfngcpt9_151gkghvfgk</url>
            <title>Torch Best Practices #1.txt</title>
            <user>Ben Smith</user>
            <category/>
        </doc>
        <doc>
            <url>http://spreadsheets.google.com/a/wbpsystems.com/ccc?key=pf10t_XtiiTlWGTD8VYP_Jg</url>
            <title>Torch Project Management Survey</title>
            <user>Ben Smith</user>
            <category/>
        </doc>
        <doc>
            <url>http://docs.google.com/a/wbpsystems.com/Doc?id=dfngcpt9_153gnq8phdw</url>
            <title>Torch Pinned Scripts.txt</title>
            <user>Ben Smith</user>
            <category/>
        </doc>
        <doc>
            <url>http://docs.google.com/a/wbpsystems.com/Doc?id=dfngcpt9_431gfpbrmf3</url>
            <title>Meeting Request</title>
            <user>Ben Smith</user>
            <category>Code Files</category>
        </doc>
    </list>
</response>

Listing Comments:

You can also get a list of comments on a particular message.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <list messagekey="2684">comments</list>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');
$list = $rxe->addChild('list', 'comments');
$list->addAttribute('messagekey','2684');
$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <list>
        <comment>
            <key>744</key>
            <body>Item's have been completed</body>
            <timestamp>2009-05-28 14:51:12</timestamp>
            <user>Ben Smith</user>
        </comment>
    </list>
</response>

Searching Events:

You search using exactly the same powerful find system as when you are in Torch. Here is a search of events.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <search>
        <type>events</type>
        <phrase>john</phrase>
    </search>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');
$search = $rxe->addChild('search');
$search->addChild('type','events');
$search->addChild('phrase','john');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <search>
        <type>events</type>
        <phrase>john</phrase>
        <event>
            <key>58</key>
            <title>checkin with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
            <pin>Ben Smith</pin>
        </event>
        <event>
            <key>59</key>
            <timestampstart>2008-06-23 00:00:00</timestampstart>
            <timestampend>2008-06-23 00:00:00</timestampend>
            <title>Call John</title>
            <location/>
            <description/>
            <complete>yes</complete>
            <category>Graphics</category>
            <pin>Ben Smith</pin>
        </event>
        <event>
            <key>60</key>
            <timestampstart>2008-06-16 12:00:01</timestampstart>
            <timestampend>2008-06-16 13:00:01</timestampend>
            <title>Talked to John about graphics</title>
            <location/>
            <description/>
            <complete>yes</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>939</key>
            <timestampstart>2009-03-05 12:00:01</timestampstart>
            <timestampend>2009-03-05 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>940</key>
            <timestampstart>2009-03-12 12:00:01</timestampstart>
            <timestampend>2009-03-12 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>941</key>
            <timestampstart>2009-03-19 12:00:01</timestampstart>
            <timestampend>2009-03-19 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>942</key>
            <timestampstart>2009-03-26 12:00:01</timestampstart>
            <timestampend>2009-03-26 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>943</key>
            <timestampstart>2009-05-05 12:00:01</timestampstart>
            <timestampend>2009-05-05 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
    </search>
</response>

Searching Messages:

You search using exactly the same powerful find system as when you are in Torch. Here is a search of messages (make note of the follow-up events).

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <search>
        <type>messages</type>
        <phrase>design</phrase>
    </search>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$search = $rxe->addChild('search');
$search->addChild('type','messages');
$search->addChild('phrase','design');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <search>
        <type>messages</type>
        <phrase>design</phrase>
        <message>
            <key>52</key>
            <subject>Website Design File</subject>
            <body>John this is the design image you requested.

Ben</body>
            <emailto>john@doe.com, Website_Design+creativearc@mytorch.net</emailto>
            <emailfrom>Ben Smith &lt;ben@wbpsystems.com&gt;</emailfrom>
            <user>Ben Smith</user>
            <pin>Ben Smith</pin>
        </message>
        <message>
            <key>53</key>
            <subject>Final Graphics File</subject>
            <body>This is the final design</body>
            <emailto/>
            <emailfrom/>
            <user>Ben Smith</user>
            <pin>Ben Smith</pin>
            <followupevent>
                <key>58</key>
                <title>checkin with John</title>
                <location/>
                <description/>
                <complete>no</complete>
                <category>Graphics</category>
                <pin>Ben Smith</pin>
            </followupevent>
            <followupevent>
                <key>59</key>
                <timestampstart>2008-06-23 00:00:00</timestampstart>
                <timestampend>2008-06-23 00:00:00</timestampend>
                <title>Call John</title>
                <location/>
                <description/>
                <complete>yes</complete>
                <category>Graphics</category>
                <pin>Ben Smith</pin>
            </followupevent>
        </message>
    </search>
</response>

Inserting Projects:

You can insert projects by just wrapping the field with the node “insert”.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <insert>
        <project>New Project</project>
    </insert>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);


$insert = $rxe->addChild('insert');
$project = $insert->addChild('project','New Project');
$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <insert>
        <project>project inserted</project>
    </insert>
    <project token="TOKEN" key="2535" archive="false">New Project</project>
    <project token="TOKEN" key="1972" archive="false">Jan's Project</project>
    <project token="TOKEN" key="18" archive="false">Newsletter Graphics</project>
    <project token="TOKEN" key="13" archive="false">WebSite Design</project>
    <project token="TOKEN" key="1935" archive="true">Demo</project>
</response>

You can also specify a budget by creating an attribute of the “project” node.

Inserting Categories:

You can insert categories by just wrapping the field with the node “insert”.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <insert>
        <category>new category from API</category>
    </insert>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$insert = $rxe->addChild('insert');
$insert ->addChild('category','new category from API');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <insert>
        <category>category inserted</category>
    </insert>
</response>

Inserting Time:

You can insert time by just wrapping the node with the node “insert”. Time entries require an user and hours.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <insert>
        <time>
            <category>code files</category>
            <user>Ben Smith</user>
            <hours>1.5</hours>
            <date>today</date>
            <note>bug fix</note>
        </time>
    </insert>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$insert = $rxe->addChild('insert');
$time = $insert->addChild('time');
$time->addChild('category','code files');
$time->addChild('user','Ben Smith');
$time->addChild('hours','1.5');
$time->addChild('date','today');
$time->addChild('note','bug fix');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <insert>
        <time>time inserted</time>
    </insert>
</response>

Inserting Expenses:

You can insert expense by just wrapping the node with the node “insert”. Expense entries require an user and price.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <insert>
        <expense>
            <category>code files</category>
            <user>Ben Smith</user>
            <price>200</hours>
            <date>today</date>
            <note>production kit</note>
        </expense>
    </insert>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$insert = $rxe->addChild('insert');
$time = $insert->addChild('expense');
$time->addChild('category','code files');
$time->addChild('user','Ben Smith');
$time->addChild('price','200');
$time->addChild('date','today');
$time->addChild('note','production kit');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <insert>
        <expense>expense inserted</expense>
    </insert>
</response>

Inserting Comments:

You can insert a comment by just including a message key and wrapping it with the node “insert”.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <insert>
        <comment messagekey="2684">The client has been informed</comment>
    </insert>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$insert = $rxe->addChild('insert');
$comment = $insert->addChild('comment','The client has been informed');
$comment->addAttribute('messagekey','2684');
$post = $rxe->asXML();



$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <insert>
        <comment>comment inserted</comment>
    </insert>
</response>

Inserting Events:

You can insert events by just wrapping the node with the node “insert”. Events require start and stop times as well as a title.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <insert>
        <event>
            <category>search</category>
            <title>test event from API</title>
            <timestampstart>today</timestampstart>
            <timestampend>today</timestampend>
            <location>location</location>
            <description>description</description>
            <pin>Ben Smith</pin>
            <pin>James</pin>
            <complete>yes</complete>
        </event>
    </insert>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$insert = $rxe->addChild('insert');
$event = $insert->addChild('event');
$event->addChild('category','search');
$event->addChild('title','test event from API');
$event->addChild('timestampstart','today');
$event->addChild('timestampend','today');
$event->addChild('location','location');
$event->addChild('description','description');
$event->addChild('pin','Ben Smith');
$event->addChild('pin','James');
$event->addChild('complete','yes');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <insert>
        <event>event inserted</event>
    </insert>
</response>

Inserting Messages:

You can insert messages by just wrapping the node with the node “insert”. Messages require a title. Also note the ability to insert follow-up events.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <insert>
        <message>
            <subject>new message from API</subject>
            <body>body</body>
            <category>search</category>
            <pin>Ben Smith</pin>
            <followupevent>
                <category>search</category>
                <title>test event from API</title>
                <timestampstart>today</timestampstart>
                <timestampend>today</timestampend>
                <location>location</location>
                <description>description</description>
                <pin>James</pin>
                <complete>yes</complete>
            </followupevent>
        </message>
    </insert>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$insert = $rxe->addChild('insert');
$message = $insert->addChild('message');
$message->addChild('subject','new message from API');
$message->addChild('body','body');
$message->addChild('category','search');
$message->addChild('pin','Ben Smith');
$event = $message->addChild('followupevent');
$event->addChild('category','search');
$event->addChild('title','test event from API');
$event->addChild('timestampstart','today');
$event->addChild('timestampend','today');
$event->addChild('location','location');
$event->addChild('description','description');
$event->addChild('pin','James');
$event->addChild('complete','yes');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <insert>
        <message>message inserted</message>
    </insert>
</response>

Update Events/Tasks:

You can update events by just wrapping the node with the node “update”. Events require start and stop times as well as a title and key.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <update>
        <event key="1156">
            <category>code files</category>
            <title>update event from API</title>
            <timestampstart>+2 week</timestampstart>
            <timestampend>+2 week</timestampend>
            <location>my location</location>
            <description>my description</description>
            <pin>Ben Smith</pin>
            <complete>yes</complete>
        </event>
    </update>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$update = $rxe->addChild('update');
$event = $update->addChild('event');
$event->addAttribute('key','1156');
$event->addChild('category','code files');
$event->addChild('title','update event from API');
$event->addChild('timestampstart','+2 week');
$event->addChild('timestampend','+2 week');
$event->addChild('location','my location');
$event->addChild('description','my description');
$event->addChild('pin','Ben Smith');
$event->addChild('complete','yes');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <update>
        <event>event updated</event>
    </update>
</response>

Update Messages:

You can update messages by just wrapping the node with the node “update”. Messages require a title and a key. Also note the ability to insert follow-up events (these are in addition to the existing follow-up events).

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <update>
        <message key="2684">
            <subject>Updated message from API</subject>
            <body>body updated</body>
            <category>code files</category>
            <pin>Ben Smith</pin>
            <followupevent>
                <category>search</category>
                <title>test event from API</title>
                <timestampstart>today</timestampstart>
                <timestampend>today</timestampend>
                <location>location</location>
                <description>description</description>
                <pin>James</pin>
                <complete>no</complete>
            </followupevent>
        </message>
    </update>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$update = $rxe->addChild('update');
$message = $update->addChild('message');
$message->addAttribute('key','2684');
$message->addChild('subject','Updated message from API');
$message->addChild('body','body updated');
$message->addChild('category','code files');
$message->addChild('pin','Ben Smith');
$event = $message->addChild('followupevent');
$event->addChild('category','search');
$event->addChild('title','test event from API');
$event->addChild('timestampstart','today');
$event->addChild('timestampend','today');
$event->addChild('location','location');
$event->addChild('description','description');
$event->addChild('pin','James');
$event->addChild('complete','no');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <update>
        <message>message updated</message>
    </update>
</response>

Complete Events/Tasks:

You can complete events by selecting them either by key or title.

In XML, the request via key looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <complete>
        <key>1077</key>
    </complete>
</request>

In XML, the request via title looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <complete>
        <title>Lunch with John</title>
    </complete>
</request>

In PHP, the request via title looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);
$rxe->addChild('project','website design');
$complete = $rxe->addChild('complete');
$complete->addChild('title','Lunch with John');


$post = $rxe->asXML();


$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <complete>event completed</complete>
</response>

Combining Requests:

You can combine up to twenty requests into a single XML document, for instance you can get multiple lists and searches.

In XML, the request looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<request>
    <project>website design</project>
    <list>categories</list>
    <list>time</list>
    <search>
        <type>messages</type>
        <phrase>john</phrase>
    </search>
    <search>
        <type>events</type>
        <phrase>john</phrase>
    </search>
</request>

In PHP, the request looks like this:

Code:

<?php
$username = "ben@wbpsystems.com";
$password = "password";

$xmltext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request></request>";
$rxe = new SimpleXMLElement($xmltext);

$rxe->addChild('project','website design');

$list = $rxe->addChild('list', 'categories');
$list = $rxe->addChild('list', 'time');

$search = $rxe->addChild('search');
$search->addChild('type','messages');
$search->addChild('phrase','john');

$search = $rxe->addChild('search');
$search->addChild('type','events');
$search->addChild('phrase','john');

$post = $rxe->asXML();

$ch = curl_init (); 
curl_setopt($ch,CURLOPT_URL,"https://creativearc.mytorch.net/api.php"); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post); 
$result = curl_exec ($ch); 

curl_close($ch);

file_put_contents ('output.xml',$result);
?>

The response looks like this:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<response>
    <list>
        <category>Graphics</category>
        <category>Code Files</category>
        <category>new category from API</category>
    </list>
    <list>
        <time>
            <key>13</key>
            <timestamp>2008-06-16 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>Designed Front Page</note>
            <category>Graphics</category>
            <invoicename/>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>14</key>
            <timestamp>2008-06-16 00:00:00</timestamp>
            <hours>0.500000</hours>
            <note>Sub Page One</note>
            <category>Graphics</category>
            <invoicename/>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>15</key>
            <timestamp>2008-06-16 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>Talked to John on Phone</note>
            <category>Graphics</category>
            <invoicename/>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>86</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>Some Graphics work in August</note>
            <category>Graphics</category>
            <invoicename/>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>87</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>2.000000</hours>
            <note>Meeting with John</note>
            <category>Graphics</category>
            <invoicename/>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>88</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>Write some code for John</note>
            <category>Code Files</category>
            <invoicename>1001</invoicename>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>89</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>0.500000</hours>
            <note>Review Code with John</note>
            <category>Code Files</category>
            <invoicename>1001</invoicename>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>90</key>
            <timestamp>2008-08-23 00:00:00</timestamp>
            <hours>1.000000</hours>
            <note>More Code Work after first Invoice</note>
            <category>Code Files</category>
            <invoicename>1002</invoicename>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>339</key>
            <timestamp>2009-05-22 00:00:00</timestamp>
            <hours>1.500000</hours>
            <note/>
            <category>Code Files</category>
            <invoicename/>
            <user>Ben Smith</user>
        </time>
        <time>
            <key>340</key>
            <timestamp>2009-05-22 00:00:00</timestamp>
            <hours>1.500000</hours>
            <note>bug fix</note>
            <category>Code Files</category>
            <invoicename/>
            <user>Ben Smith</user>
        </time>
    </list>
    <search>
        <type>messages</type>
        <phrase>john</phrase>
        <message>
            <key>52</key>
            <subject>Website Design File</subject>
            <body>John this is the design image you requested.

Ben</body>
            <emailto>john@doe.com, Website_Design+creativearc@mytorch.net</emailto>
            <emailfrom>Ben Smith &lt;ben@wbpsystems.com&gt;</emailfrom>
            <user>Ben Smith</user>
            <pin>Ben Smith</pin>
        </message>
        <message>
            <key>54</key>
            <subject>Meeting</subject>
            <body>We need to meet to discuss graphics.


-- 
Ben Smith
Founder / CSA
WBP SYSTEMS
http://www.wbpsystems.com</body>
            <emailto>John@doe.com</emailto>
            <emailfrom>Ben Smith &lt;ben@wbpsystems.com&gt;</emailfrom>
            <user>Ben Smith</user>
        </message>
        <message>
            <key>137</key>
            <subject>John I need a Go Ahead</subject>
            <body>Hi John I need to know if I can move forward.</body>
            <emailto/>
            <emailfrom/>
            <user>Ben Smith</user>
            <pin>John Doe</pin>
        </message>
        <message>
            <key>138</key>
            <subject>Message about the meeting</subject>
            <body>We need to have a meeting.

-- 
Ben Smith
Founder / CSA
WBP SYSTEMS
http://www.wbpsystems.com</body>
            <emailto>John@doe.com</emailto>
            <emailfrom>Ben Smith &lt;ben@wbpsystems.com&gt;</emailfrom>
            <user>Ben Smith</user>
        </message>
    </search>
    <search>
        <type>events</type>
        <phrase>john</phrase>
        <event>
            <key>58</key>
            <title>checkin with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
            <pin>Ben Smith</pin>
        </event>
        <event>
            <key>59</key>
            <timestampstart>2008-06-23 00:00:00</timestampstart>
            <timestampend>2008-06-23 00:00:00</timestampend>
            <title>Call John</title>
            <location/>
            <description/>
            <complete>yes</complete>
            <category>Graphics</category>
            <pin>Ben Smith</pin>
        </event>
        <event>
            <key>60</key>
            <timestampstart>2008-06-16 12:00:01</timestampstart>
            <timestampend>2008-06-16 13:00:01</timestampend>
            <title>Talked to John about graphics</title>
            <location/>
            <description/>
            <complete>yes</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>939</key>
            <timestampstart>2009-03-05 12:00:01</timestampstart>
            <timestampend>2009-03-05 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>940</key>
            <timestampstart>2009-03-12 12:00:01</timestampstart>
            <timestampend>2009-03-12 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>941</key>
            <timestampstart>2009-03-19 12:00:01</timestampstart>
            <timestampend>2009-03-19 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>942</key>
            <timestampstart>2009-03-26 12:00:01</timestampstart>
            <timestampend>2009-03-26 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
        <event>
            <key>943</key>
            <timestampstart>2009-05-05 12:00:01</timestampstart>
            <timestampend>2009-05-05 13:00:01</timestampend>
            <title>Lunch with John</title>
            <location/>
            <description/>
            <complete>no</complete>
            <category>Graphics</category>
        </event>
    </search>
</response>