Not signed in (Sign In)
  • What is Intervals?

    Intervals is online time, task and project management software built by and for web designers, developers and creatives. Learn more…

The Intervals Forum is read-only
Please head to help.myintervals.com for help articles and guides. If you have any questions, please contact our support team.

API

API PHP Code Sample: Create a Task

Bottom of Page

  1.  
  1.  

    In this PHP code sample we'll see how to create a task from XML data using the API and the Curl library. When using this code, remember to replace variable values with your own to avoid errors.

    The API documentation for the task resource can be found at:
    https://www.myintervals.com/api/resource.php?r=task


    //create the xml file to POST
    $putString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    $putString .= "<task>\n";
    $putString .= "<statusid>67329</statusid>\n";
    $putString .= "<projectid>920391</projectid>\n";
    $putString .= "<moduleid>667821</moduleid>\n";
    $putString .= "<title>New Task</title>\n";
    $putString .= "<dateopen>2010-05-26</dateopen>\n";
    $putString .= "<datedue>2010-05-29</datedue>\n";
    $putString .= "<priorityid>46781</priorityid>\n";
    $putString .= "<ownerid>97351</ownerid>\n";
    $putString .= "<assigneeid>101881, 100283</assigneeid>\n";
    $putString .= "<summary>A summary of the task</summary>\n";
    $putString .= "</task>\n";

    //set api token value to your api token
    $apiToken = "";

    //intialize and send the curl request
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.myintervals.com/task");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERPWD, $apiToken. ":");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Content-type: application/xml"));
    //POST
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $putString);
    $response = curl_exec($ch);
    curl_close($ch);

    //output the resulting XML
    echo $response;

Comments are closed.
For more Intervals help documentation, please visit help.myintervals.com