significance and source of task id
In lieu of an API, I'd like to use PHP and cURL with my browsers cookie cache to emulate adding tasks via the browser.
I'm needing to input 60 some tasks and I'd rather do so via a script than my poor hands on a keyboard. In studying the POST that results from creating a task, I find most of it makes sense, but I'm not sure how important the id is (can I successfully submit without one?) or how to create a valid one.
Support Staff 2 Posted by Mitchell Amihod on 16 Jan, 2012 04:39 PM
hey tara, you need the id. You need to generate one for new tasks.
You can examine how its done in the ruby gem https://github.com/meeech/nirv/blob/master/lib/nirvanahq/task.rb#L1... where I prepare the payload, you can see the defaults I set. You could use that to script on the CLI as well.
Here's a copy of the UUID function nirvana uses (javascript)
hope this helps
m
3 Posted by Proximo on 16 Jan, 2012 06:56 PM
I think Programmers are soooooo cool.
The hieroglyphics posted above mean nothing to someone like me, but I still think it's cool to look at. :-)
"Yes, the flex capacitor linear output needs to hook with the induction modulator in order to extract the package via. encrypted sets of atomic plasma energy."
WHAT?
When you guys are done with creating some cool extensions or web apps, just let me know were to download them and make sure the only option I have is "Next, Next.... OK".
Let me get back to my 3D Design and Animation work.
4 Posted by Tara on 16 Jan, 2012 11:43 PM
@Mitchell, thanks for the info, i'll get cracking on that
@proximo, it's all relative. i found myself standing on my head in SketchUp,
Support Staff 5 Posted by Mitchell Amihod on 17 Jan, 2012 12:13 AM
@tara coo. hit me up here or on twitter (@meeech) if you have any problems.
@proximo what tara said! :D
6 Posted by Proximo on 19 Jan, 2012 05:24 AM
ROFL
I am trying to learn Java Script, HTML 5 and CSS.
Not easy for me but I am trying.
Designing a complex surface model or a large 3D assembly with many components is easy for me. So I guess it is all relative.
7 Posted by tara on 29 Mar, 2012 05:31 PM
FWIW, I just used my hacky little script a second time to enter my favorite 10k training plan into nirvana for a future race. It only took a few minutes to enter over 100 items. (minutes to remember how to run it, seconds for it to run)
This is not to pat myself on the back, but to thank you both for the help and encouragement in this thread.
I have never succeeded in jumping authentication hoops with cURL and I end up cheating and exporting my browsers cookies to borrow the authentication that I've already established.
8 Posted by Grant on 29 Mar, 2012 06:22 PM
Is there any way you might share said script? :-)
9 Posted by tara on 29 Mar, 2012 06:57 PM
Sure, but let me describe it first to gauge interest.
It's a PHP script that connects to a mysql database to fetch the tasks to enter. Because it isn't sophisticated, I hard code a target date and calculate the other 60 task due dates based on that. I have also hard coded a base url based on what my browser did when I entered a task manually. I already mentioned the cookie/authentication workaround.
If you're still interested in the hack and workaround and other constraints, let me know and I'll post it here.
10 Posted by Grant on 30 Mar, 2012 12:40 PM
I'm a bit new to RESTful APIs and my attempts so far with what was discussed here using something like C++ have so far been unsuccessful. It would be great to see an example of a "third party" interface working. PHP isn't something new to me but I'm more in the embedded software area now having left the web development days several year ago.
Support Staff 11 Posted by Mitchell Amihod on 30 Mar, 2012 06:19 PM
grant - you can always check out the source of https://github.com/meeech/nirv
12 Posted by tara on 01 Apr, 2012 08:01 PM
uh, ok.. .did I mention this is a hack.. a hacky hack at that?
<?php
$test = true;
$dbhost = "localhost:8889"; $dbname = "db"; $dbuser = "dba"; $dbpass = "pw";
$db = dbConnect($dbname);
$plan_id = 2; //1=5k, 2=10k
$query = "SELECT * from plan where plan_id=$plan_id"; $result = mysql_query($query); while($row = mysql_fetch_object($result)){
}
$base = 'https://api.nirvanahq.com/?api=json&requestid=093C76EE-4CC4-400...';
$query = 'SELECT * FROM details WHERE plan_id=1 ORDER BY day'; $race_date = '7/22/2012'; $unixrace = strtotime($race_date); $startday = $unixrace - ($plan->day_of_race * 60 * 60 * 24); $result = mysql_query($query); while($row = mysql_fetch_object($result)){
}
function dbConnect($db) {
global $dbhost, $dbuser, $dbpass; $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
if ($db!="" and !@mysql_select_db($db))
return $dbcnx; }
function postToNirvana($item, &$ch){
}
function genUUID(){
}
function report($message){
} ?>
Support Staff 13 Posted by Mitchell Amihod on 01 Apr, 2012 08:05 PM
@tara - formatting is messed up. Might want to just drop it in a gist ( gist.github.com ) and post link to it.
14 Posted by tara on 01 Apr, 2012 08:12 PM
https://gist.github.com/2278294
thanks meech!
15 Posted by Grant on 01 Apr, 2012 11:26 PM
Looks like a little healthy reverse engineering :-P