For our final recipe, we're going to put everything together and, using a combination of our previous recipe's "image post" functionality and the Birdhouse API, post a tweet containing a message from our app and the image URL that accompanies it.
Note
Complete source code for this recipe can be found in the /Chapter 5/Recipe 8
folder.
Complete source code for this entire chapter can be found in the /Chapter 5/PhotoShare
folder.
Alter the postToTwitter
function in your existing app.js
file to match the following code by adding our new BH.tweet
method call. If you already integrated the photo upload code from the previous recipe, then this source code snippet should appear in the xhr.onload()
event handler:
BH.tweet(txtMessage.value + ' ' + this.responseText, function(){ alertDialog = Ti.UI.createAlertDialog({ message:'Tweet posted!' }); alertDialog.show(); });
Try running your application now in the simulator, and after...