Created
April 11, 2012 05:02
-
-
Save Clancey/2357027 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void sendTweet(string updateText) | |
{ | |
ACAccountStore account = new ACAccountStore(); | |
var accountType = account.FindAccountType(ACAccountType.Twitter); | |
account.RequestAccess(accountType,(granted,NSError)=> { | |
if(!granted) | |
return; | |
var arrayOfAccounts = account.FindAccounts(accountType); | |
if(arrayOfAccounts != null && arrayOfAccounts.Length == 0) | |
return; | |
TWRequest postRequest = new TWRequest ( new NSUrl (@"http://api.twitter.com/1/statuses/update.json"), NSDictionary.FromObjectAndKey (NSObject.FromObject (updateText.ToString() + "\r\n"), NSObject.FromObject ("status")), TWRequestMethod.Post); | |
postRequest.Account = arrayOfAccounts[0]; | |
postRequest.PerformRequest ((responseData, urlResponse, error) =>{ | |
InvokeOnMainThread (() =>{ | |
if(urlResponse.StatusCode == 200){ | |
new UIAlertView("Success", "Tweet Posted \n" + responseData.ToString (),null,"Ok",null).Show (); | |
} | |
else { | |
new UIAlertView("Oh Noes!", "Error \n" + error.ToString(),null,"Ok",null).Show (); | |
} | |
} | |
); | |
} ); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment