Original address: iOS 6 Social application development-Sina Weibo
1. Add framework.
2. Import the header file.
#import <Accounts/Accounts.h>#import <Social/Social.h>
3. Make sure that the account for the social networking application is configured in "Settings" (take Sina Weibo as an example), as shown in.
4. Get Sina Weibo users.
// Obtain the account storage acaccountstore * strore = [[acaccountstore alloc] init]; // obtain the Account type of Sina Weibo acaccounttype * type = [strore accounttypewithaccounttypeidentifier: acaccounttypeidentifiersinaweibo]; // verify whether a matched account is configured [strore requestaccesstoaccountswithtype: type options: Nil completion: ^ (bool granted, nserror * error) {If (granted) // Authorization verified {// retrieve Sina Weibo user list nsarray * counts = [strore accountswithaccounttype: type]; If (counts & [counts count]> 0) {// authentication passed // take the first user as an example [self requestwithaccount: [counts objectatindex: 0] ;}}];
5. Publish Weibo.
Sina Weibo interface documentation
-(Void) requestwithaccount :( acaccount *) account {/* // type slservicetypetwitter slservicetypefacebook success // method slrequestmethodget slrequestmethodpost slrequestmethoddelete * // request address, see nsurl * url = [nsurl urlwithstring: @ "https://open.weibo.cn/2/statuses/update"]; // configure the parameter dictionary nsdictionary * para = [nsdictionary dictionarywithobjectsandkeys: @ "ssstext", @ "status ", nil]; // configure a lightweight slrequest * Request = [slrequest requestforservicetype: slservicetypesinaweibo requestmethod: slrequestmethodget URL: URL parameters: para]; // load the Weibo user request. account = Account; // send Weibo [request processing mrequestwithhandler: ^ (nsdata * responsedata, nshttpurlresponse * urlresponse, nserror * error) {If (! Error) {// UI dispatch_async (dispatch_get_main_queue (), ^ {nsstring * response = [[nsstring alloc] initwithdata: responsedata encoding: nsutf8stringencoding] in the main thread; nslog (@ "request result: % @", response); // operation UI}) ;}}];}