1
이것은 Sam입니다. 현재 내 응용 프로그램에서 twitter 공유를 devloping하고 있습니다. ComposeController없이 구현해야합니다. 소셜 프레임 워크의 SLRequest와 통합해야합니다. 내가 사용 강령은 다음과 같이SLRequest와 Twitter 공유
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *twitterAccountType =[accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:twitterAccountType options:NULL completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Creating Request");
// Step 2: Create a request
NSArray *twitterAccounts =[accountStore accountsWithAccountType:twitterAccountType];
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.0/statuses/update.json"];
NSDictionary *params = @{@"screen_name" : @"naheshsamy",@"include_rts" : @"0",@"trim_user" : @"1",@"count" : @"1"};
SLRequest *request =
[SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:url parameters:params];
// Attach an account to the request
[request setAccount:[twitterAccounts lastObject]];
NSLog(@"Request %@",request);
// Step 3: Execute the request
[request performRequestWithHandler: ^(NSData *responseData,NSHTTPURLResponse *urlResponse,NSError *error) {
if (responseData) {
if (urlResponse.statusCode >= 200 && urlResponse.statusCode < 300) {
NSError *jsonError;
NSDictionary *timelineData = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:&jsonError];
if (timelineData) {
NSLog(@"Timeline Response: %@\n", timelineData);
}
else {
// Our JSON deserialization went awry
NSLog(@"JSON Error: %@", [jsonError localizedDescription]);
}
}
else {
// The server did not respond ... were we rate-limited?
NSLog(@"The response status code is %d %@ %@",urlResponse.statusCode,urlResponse.suggestedFilename,error);
}
}
}];
}
else {
// Access was not granted, or an error occurred
NSLog(@"%@", [error localizedDescription]);
}
}];
난 항상 상태 400 오류가 있어요 .. 어떤 도움을 이해할 수있을 것이다 등이다. 감사합니다. Sam.P
당신의 귀중한 답변을 주셔서 감사합니다. 리라 ... 지금은 트위터 API를 사용하여 성공 공유를 얻었습니다. 이제 기본 트위터 계정을 사용하지 않고 액세스 토큰과 공유하는 방법을 알아야합니다. – MaheThiru