IOS 6 Social application development-Sina Weibo

Source: Internet
Author: User

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}) ;}}];}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.