2014-09-05 1 views
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

답변

2

코드는 내가 사용했던 것과 비슷합니다. 그들은 API의 버전 1.0이 더 이상 지원되지 않으며 작동하지 않을 수도 있다고 경고했습니다. 1.1로 변경하여 문제가 해결되는지 확인하십시오.

@"https://api.twitter.com/1.1/statuses/update.json" 
+0

당신의 귀중한 답변을 주셔서 감사합니다. 리라 ... 지금은 트위터 API를 사용하여 성공 공유를 얻었습니다. 이제 기본 트위터 계정을 사용하지 않고 액세스 토큰과 공유하는 방법을 알아야합니다. – MaheThiru

관련 문제