In the previous blog iOS development Sina Scarf to get the content is the use of my own access_token to request the data, so how to let other users can also access to the content of their own Weibo? The next step is OAuth and SSO. OAuth is all called open Authorization development Authorization, sso--single-point login. As to what the principle is, more specific information on the Internet is a catch a lot, in this do not do too much of the principle of the outline. Of course, OAuth and SSO are a lot of applications on the web and other mobile devices, and all this information is much more.
In short, it is possible to use Sina's OAuth to replace the former Access_token with the user's own Access_token, in order to request the content of their microblog (because of what has been done about Sina Weibo, so it uses the OAuth provided by Sina). For more detailed information, please refer to Sina's OAuth2.0 licensing , the iOS SDK GitHub download is as follows:HTTPS://GITHUB.COM/SINAWEIBOSDK/WEIBO_IOS_SDK There are detailed instructions and use of demo. So the use of the SDK in this will not do too much to repeat. Perhaps some of the small partners will ask which of the blog to introduce what things? This blog is by the previous Sina Weibo plus OAuth authorization certification, to the previous blog to do a aftercare work.
1. Or at the beginning of the blog first a few (the first is not logged in when the start diagram, the second is to obtain the authorization of the page, the third is the authorized page, the fourth is the previous written iOS development of the custom emoji keyboard (component encapsulation and automatic layout) integration) In this way, the basic function of an app is there.
2. In today's blog does not have a large number of code, just to the previous blog content of an application, how to use Sina's OAuth SDK, Sina to provide the development documentation described in very detailed, the author also follow the above step by step, there is no big problem. The SDK is given above, and interested partners can download a research study.
3. After the user authorizes, the Sina interface or returns some user's information, among them has this authorized user's corresponding Access_token, below is the response code, the return user Access_token deposit in the Nsuserdefaults, For details on Nsuserdefault, please refer to the previous blog iOS development record user login status , in this do not repeat.
1- (void) Didreceiveweiboresponse: (Wbbaseresponse *) Response2 {3 if([Response iskindofclass:wbsendmessagetoweiboresponse.class])4 {5NSString *title =@"Send Results";6NSString *message = [NSString stringWithFormat:@"Response Status:%d\n response userinfo Data:%@\n original request userinfo data:%@",7 Response.statuscode, Response.userinfo, Response.requestuserinfo];8NSLog (@"%@", message);9 }Ten Else if([Response iskindofclass:wbauthorizeresponse.class]) One { A -Self.wbtoken = [(Wbauthorizeresponse *) response Accesstoken]; - the if(Self.wbtoken! =Nil) { - //get Userdefault single case -Nsuserdefaults *token =[Nsuserdefaults standarduserdefaults]; -[Token SetObject:self.wbtoken Forkey:@"token"]; + } - } +}
4. Add our custom keyboard is also quite simple, because before is a pure code encapsulated custom keyboard and left a responsive interface, all ported to our Sina Weibo is a copy of the manual work, about the custom keyboard, please refer to the previous blog iOS developed custom emoji keyboard ( Component encapsulation and automatic layout), do not repeat in this.
This blog as a summary of the previous development of Sina Weibo, remember that there is a blog in front of the development of the Android version of the cottage, in fact, in this blog only view between the relationship, no specific business logic, in the next period of time to improve the Shanzhai version, and add real-time communication content, I hope members will continue to pay attention.
Sina Weibo summary of Android development