-(void)sinaWeibo{
ACAccountStore *account=[[ACAccountStore alloc] init]; //本机账户数据库, 储存weibo,facebook等各种账户
ACAccountType *accountType=[account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierSinaWeibo];
NSLog(@"accountType:%@",accountType);
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"认证通过");
if (!self.content.text) {
UIAlertView *a=[[UIAlertView alloc] initWithTitle:@"提示" message:@"请输入要发分享的内容" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[a show];
return ;
}
NSArray *arrayAccounts=[account accountsWithAccountType:accountType];
NSLog(@"arrayAccounts:%@",arrayAccounts);
if ([arrayAccounts count]>0) {
// NSLog(@"认证通过");
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeSinaWeibo
requestMethod:SLRequestMethodPOST
URL:[NSURL URLWithString:@"https://upload.api.weibo.com/2/statuses/upload.json"]
parameters:@{@"status": self.content.text}];
NSLog(@"account:%@",[[arrayAccounts objectAtIndex:0] class]);
request.account=[arrayAccounts objectAtIndex:0] ;
[request addMultipartData:self.imageData withName:@"pic" type:@"multipart/form-data" filename:@"a.png"];
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
id jsonObj = [NSJSONSerialization JSONObjectWithData:responseData
options:NSJSONReadingAllowFragments error:&error];
NSLog(@"jsonObj:%@",jsonObj);
if (!error) {
NSLog(@"%@",[jsonObj objectForKey:@"statuses"]) ; //key更具api json决定
UIAlertView *a=[[UIAlertView alloc] initWithTitle:@"提示" message:@"分享成功" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[a show];
}
}];
}else{
UIAlertView *a=[[UIAlertView alloc] initWithTitle:@"提示" message:@"无效账户,请到设置界面设置账号信息" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[a show];
}
}
}];
}
相关推荐
微信小程序源码-新浪读书.zip微信小程序源码-新浪读书.zip微信小程序源码-新浪读书.zip微信小程序源码-新浪读书.zip微信小程序源码-新浪读书.zip微信小程序源码-新浪读书.zip微信小程序源码-新浪读书.zip微信小程序...
杨皓-新浪博客前端架构分享 杨皓-新浪博客前端架构分享 杨皓-新浪博客前端架构分享 杨皓-新浪博客前端架构分享 杨皓-新浪博客前端架构分享
新浪博客抓取小程序 安装 npm install -g dature 使用 抓取新浪博客的数据(标题、正文、时间、分类、图片),保存为blog/data.json,并生成HTML文件 dature -cu sina_blog_uid 或 dature --create --uid sina_...
2018新浪媒体白皮书-新浪-201811.pdf
swot-新浪分析.pdf
通过获取到的CODE 直接编写帮忙处理token 拿到 uid
新浪网研发中心平台架构部 总监撰写的 NetApp用户案例-新浪-IT基础架构回顾与展望.ppt
本科毕业设计---新浪微博android客户端的实现.docx
微信--新浪--QQ空间,分享功能,点击图标进入第三方登陆,并分享
iOS-sina微博登录 xcode4 6
零散MATLAB资料分享-MATLAB中GUI设计领悟-SINA_隐藏.docx 最近在用MATLAB做一个项目,自然需要查很多东西,在网上搜集了一点资料,并非原创。本着分享的精神,希望能帮助到部分人。 包括以下内容 在...
ssd知识分享-新浪内部 ssd知识入门与提高
本科毕业设计-----新浪微博android客户端的实现
安卓-新浪微博的换页,源码,项目源码.直接可用.测试通过
XXXX-Q1-新浪微博客产品-营销思路框架-0222-V1.pptx
评论-新浪微博是新浪唯一的救命稻草.docx
毕业设计 微信小程序设计-----新浪读书.rar
Linux运维工程师笔试题-新浪-及-系统工程师笔试题.docx
PPT报告:唐硕-2009-7-新浪微博客 腾讯滔滔竞争分析报告_ V1.0.pdf