Skip to content

Instantly share code, notes, and snippets.

@turusuke
Created September 25, 2016 06:47
Show Gist options
  • Save turusuke/eac839a48234d773de19f6525e108416 to your computer and use it in GitHub Desktop.
Save turusuke/eac839a48234d773de19f6525e108416 to your computer and use it in GitHub Desktop.
<?php
$api_token = 'YOUR_API_TOKEN';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, 'https://www.toggl.com/api/v8/time_entries/start');
curl_setopt($ch, CURLOPT_USERPWD, $api_token . ": api_token");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$created_with='alfred';
$billable=true;
$workspace_id = '';
$description = 'お散歩';
$start = 'TIME ENTRY START IN MILLISECONDS; SEE API DOC';
$data['time_entry'] = array(
'billable' => $billable,
'workspace' => array('id' => 'YOUR_WORKSPACE_ID'),
'description' => $description,
'created_with' => $created_with
);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$result = curl_exec($ch);
echo json_encode($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment