[Delicious-java-discuss] addPost()
Brought to you by:
czarneckid
From: Discussion l. f. delicious-j. <del...@li...> - 2006-06-06 03:02:23
|
Hi, I am still trying to work through the problem I'm having with the addPost() method ceasing to work after updating the 29th post. I've creaed a stripped down version of my program as an example of the problem. I've copied it below (it can also be seen here http:// boydstudio.ca/p5/deliciousExample1.pde ). This example program tried up add a tag called 'deleteLater' to all the Posts. Running on my computer it stalls after the 28th or 29th post. If you have any suggestions or ideas I'd appreciate hearing them. I'm out of ideas at this point. thanks, Steve /** * I've used some code from Marius Watz's example found * here http://processinghacks.com/hacks:delicious * (specifically the connection code and casting the bookmarks as Post objects) */ Delicious delicious; // create Delicious object called delicious Object[] o; // simple object array to be used to hold the bookmark posts to be downloaded from delicious Post[] posts; // Post array to eventually hold the bookmark posts (after they're cast into Post objects) String newTag = "deleteLater"; // for the purposes of this example this is a new tag I want to add to all my bookmarks int currentPost = 0; // current post being used int startTime; // obvious void setup() { // Initiate Delicious object. Replace username and password with your own info. delicious=new Delicious("yourUsername","yourPassword"); delay(2000); // add in a delay ensure we're not breaking the 1 transaction/second rule // I doubt its necessary here but im adding it in to be safe. getMyPosts(); // function to go and grab some bookmarks startTime=millis(); // set startTime to equal the time after the bookmarks have been grabbed. println(""); for(int i = 0; i < posts.length; i++) { // run through each post float telp=(millis()-startTime)/1000.0; // telp = total elapsed time since the grabbing the bookmarks println("Processing post number "+i+" of "+posts.length); processPost(posts[i]); } } void draw(){} // vestigial draw function. nothing doing here. everything happens in setup void getMyPosts(){ // Choose one of the two lines below for getting either all the posts just a subset of the posts // o=delicious.getAllPosts().toArray(); o=delicious.getRecentPosts("",35).toArray(); delay(2000); // add in a delay ensure we're not breaking the 1 transaction/second rule // again probably but adding it anyway // Convert the Objects to Posts posts=new Post[o.length]; // set the size of the Post array println("Del.icio.us posts retrieved: "+posts.length); for(int i=0; i<posts.length; i++) posts[i]=(Post)o[i]; // cast the bookmark Objects as Post objects // back to setup() } // process one post at a time void processPost(Post _post){ Post currPost = _post; //currPost is the post we're operating on atm String[] tags = currPost.getTagsAsArray(" "); // grab the tags for this post into an array called tags String tagString=""; for(int i = 0; i < tags.length; i++) tagString+=tags[i]+" "; tagString += newTag; // add the new tag to the tag list updatePost(currPost, tagString); // send this post and its new set of tags to be updated } void updatePost(Post _p, String _cts){ Post p = _p; String cts = _cts; p.setTag(cts); // set the new tags for this post object println("run time just before update is sent to del.icio.us is: "+ (millis()-startTime)/1000.0); boolean sent = delicious.addPost(p.getHref(), p.getDescription(), p.getExtended(), p.getTag(), p.getTimeAsDate(),true,true); // the above line (hopefully) updates the post to del.icio.us using the addPost method. delay(2000); // again, delay for 2 secs to avoid getting throttled. println("run time after sending the addPost update and running 2 sec delay: "+(millis()-startTime)/1000.0); println(" "); } |