Closed TILVince closed 9 years ago
Does the response give an error http status code?
Did you try adding the debug config flag? Can you post the complete code in a gist so i can try it out? (Without your token offcourse) Op 19 apr. 2015 19:32 schreef "TILVince" notifications@github.com:
Could you provide some guidance on how to use the v8 API to create clients (and projects and time entries) using guzzle-toggl? I can't figure out how to format and send the request (calling $toggl_client->CreateClient for clients) nor what to expect as a response. For creating a client, I tried the following, where the variables $client_name, $wid, and $client_notes are set, but the $response returns NULL:
$response = $toggl_client->CreateClient('{"client":{"name":"$client_name","wid":$wid,"notes":"$client_notes"}}');
I can get the example get-workspaces.php to function properly, and I even modified it to pull a list of clients successfully (I first manually added a test client directly in Toggl).
Thanks in advance.
— Reply to this email directly or view it on GitHub https://github.com/arendjantetteroo/guzzle-toggl/issues/11.
I enabled the debug flag, but got nothing different.
GIST is at https://gist.github.com/TILVince/e3594b9fa4cdc9e7d875
I think you need to use $client->createClient, so lowercase "create". I'll try your code in a few minutes.
Ok, so createClient or CreateClient both work.
You don't need to bother with JSON, this is handled by guzzle. So just use this:
$clientdata = array('client' => array('name' => $client_name, 'wid' => $wid, 'notes' => $client_notes)); $response = $toggl_client->CreateClient($clientdata);
The same is true for the other commands you asked about.
Can you add your example with a pull request? this is helpfull for others as well.
Thanks! That was the issue. Sorry, I'm a noob at this, and there's no example of posting data. Now I just have to figure out why Workspace clients (where the API saves them) aren't available when creating projects within the Toggl web site (that's not your problem).
Have a good night!
No problem. Let me know if you need more help. I will add some more examples that make this stuff clear :)
Could you provide some guidance on how to use the v8 API to create clients (and projects and time entries) using guzzle-toggl? I can't figure out how to format and send the request (calling $toggl_client->CreateClient for clients) nor what to expect as a response. For creating a client, I tried the following, where the variables $client_name, $wid, and $client_notes are set, but the $response returns NULL:
$response = $toggl_client->CreateClient('{"client":{"name":"$client_name","wid":$wid,"notes":"$client_notes"}}');
I can get the example get-workspaces.php to function properly, and I even modified it to pull a list of clients successfully (I first manually added a test client directly in Toggl).
Thanks in advance.