2017-12-26 24 views
0

GmailのAPIからユーザーのメールからできるだけ多くのテキストを取得しようとしています。スレッドリストID、スレッドID、履歴ID、およびスレッドの別名電子メールからのスニペットを正常に取得しました。何を達成しようとしているのは、スレッドや電子メール、または場合によっては電子メールのスレッドからすべてのテキストからスニペットを取得するだけです。ここに私のコードは、これまでのところだと私gmail apiを使用してユーザースレッドからテキストのスニペットのみを取得するにはどうすればよいですか?

- (void)fetchThreads{ 

self.output.text = @"\n Getting threads..."; 
//  NSString *threadID = @"15fb742b462acbdc"; 
//  NSString *threadID1 = @"15f56dc58e92f914"; 
//  NSString *messageID = @"0x600000453020"; 

    GTLRGmailQuery_UsersThreadsList *query = [GTLRGmailQuery_UsersThreadsList queryWithUserId:@"me"]; 


    query.q = @"in:drafts"; 
    query.userId = @"me"; 


self.service.shouldFetchNextPages = true; 
    NSLog(@"The number is 1"); 
[self.service executeQuery:query 

delegate:self 

didFinishSelector:@selector(displayResultWithTicket2:finishedWithObject:error:)]; 

} 




- (void)displayResultWithTicket2:(GTLRServiceTicket *)ticket finishedWithObject:(GTLRGmail_ListThreadsResponse *)threadResponse 
          error:(NSError *)error { 

    if (error == nil) { 

     NSMutableString *threadString = [[NSMutableString alloc] init]; 

     if (threadResponse.threads.count > 0) { 

      [threadString appendString:@"Labels:\n"]; 

      for (GTLRGmail_Thread *thread in threadResponse.threads) { 
       [threadString appendFormat:@"\n This is message %@ \n", thread]; 

      } 

     } else { 

      [threadString appendString:@"No labels found."]; 
      NSLog(@"The eror is %@", error.localizedDescription); 
     } 

     self.output.text = threadString; 

    } else { 

     [self showAlert:@"Error" message:error.localizedDescription]; 

    } 

} 

結果restults:

This is message GTLRGmail_Thread 0x604000259200: {id:"15f500862dbcee7b" snippet:"Coffin of Ankhefenmut Author: John Smith Professor: Ms. Strum Course: Survey of Art in the Western World I, ARH170 Due Date: 10/24/17 The Ancient Egyptians are one of the worlds oldest civilizations" historyId:"2636014"} 

This is message GTLRGmail_Thread 0x604000259470: {id:"15f02e206c54b910" snippet:"A Review of Alice Goffman's “On the Run” Alice Goffman's “On the Run” is a well-conducted sociological and ethnographical incite into the lives of young black youth during the “Tough on Crime”" historyId:"2636016"} 

This is message GTLRGmail_Thread 0x60400024ec70: {id:"15ec4d1581e8bf30" snippet:" Introduction to Social Research - Ms. Wynn | Due 9/28/17 | 001261311 The Tearoom Trade Study Review The sociologist Laud Humphrey's conducted a very controversial study in the" historyId:"2406852"} 

答えて

0

あなたはObjective-Cの上でこれを実装する必要があります。 Users.messages.getを使用して、「スニペット」プロパティを「フィールド」パラメータとして配置します。スニペット応答のみが返されます。

Try-itからサンプル応答が適用する:

{ 
"snippet": "Your script, testscript, has recently failed to finish successfully." 
} 
関連する問題