-(void)twitter{
ACAccountStore *account=[[ACAccountStore alloc] init]; //本机账户数据库, 储存weibo,facebook等各种账户
ACAccountType *accountType=[account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
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:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update_with_media.json"]
parameters:@{@"status": self.content.text}];
NSLog(@"account:%@",[[arrayAccounts objectAtIndex:0] class]);
request.account=[arrayAccounts objectAtIndex:0] ;
[request addMultipartData:self.imageData withName:@"media[]" 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];
}
}
}];
}
相关推荐
Laravel开发-twitter Twitter API 的支持 Twitter API的支持
前端项目-twitter-bootstrap,bootstrap是全球最受欢迎的前端组件库,用于开发响应式布局、移动设备优先的web项目。
Laravel开发-twitter Twitter API的Laravel包装。
Laravel开发-laravel-twitter 拉拉维尔的推特桥
orafile.zip,Java用于处理Oracle SQL*net.ora文件Java用于处理Oracle SQL*net.ora文件
react-node-twitter-login 演示应用程序,展示如何使用前端的React和后端的REST API(实现REST API)来实现Twitter登录。 关于 该应用程序是作为描述的材料创建。 为了创建React应用,我们使用了 。 您需要安装什么...
COVID-Twitter-BERT COVID-Twitter-BERT(CT-BERT)是基于变压器的模型,该模型在有关COVID-19的大量Twitter消息集上进行了预训练。 v2模型在9700万条推文上进行了训练(1.2B训练示例)。 当在特定领域的数据集上...
go-twitter - Go Twitter REST 和 Streaming API v1.1
前端项目-twitter-fetcher,不使用新的Twitter1.1API获取您的Twitter帖子。纯javascript!
2019Twitter中国品牌出海影响力报告-FT中文网-Twitter-201905.pdf
21-recipes-for-mining-twitter.9781449303167.55127.pdf
人工智能-项目实践-用户画像-twitter用户画像 twitter用户画像 twitter用户画像
maven-twitter-plugin-0.1.jar
discord-twitter-webhooks是一种自动化工具,可以检查的新推文,并将其发送到 Webhook。 该bot配置了配置文件或环境变量,并使用Python 3编写。 安装 (单击以展开下面的部分,以获取完整的安装说明) 获取...
艾瑞咨询报告,主要针对2010年海外微博Twitter所做。具有一定的参考价值。