我正在iOS项目中关注Google Gmail API文档,我需要使用userId,messageId和id Try out from Google从邮件中下载附件。 userId是用户的电子邮件地址, id是mailId(Try it.Enter only your EmailId) messageId是我们使用上面带有附件的id之一得到的。
到目前为止,这是我所拥有的代码:
#include<stdio.h>
#define AB "HELLO"
#define A "WORLD"
#define MAC2 A#B
void main(void)
{
printf(MAC2"\n");
}
- (void)fetchLabels {
GTLQueryGmail *query = [GTLQueryGmail queryForUsersThreadsList];
[self.service executeQuery:query
delegate:self
didFinishSelector:@selector(displayResultWithTicket:finishedWithObject:error:)];
}
- (void)displayResultWithTicket:(GTLServiceTicket *)ticket
finishedWithObject:(GTLGmailListLabelsResponse *)labelsResponse
error:(NSError *)error {
NSDictionary *allIDsDictionaryValue=[labelsResponse.JSON valueForKey:@"threads"];
NSMutableArray *allIDs=[NSMutableArray new];
for (int i=0; i<[allIDsDictionaryValue count]; i++) {
[allIDs addObject:[allIDsDictionaryValue valueForKey:@"id"]];
}
NSString *mailID=[[allIDs objectAtIndex:0]objectAtIndex:0];
NSLog(@"%@",mailID);//Ex: 14e8af86776e595b
//As of now I am using the first id only because it has an attachment.
// Getting messageId from an id of a mail.
GTLQueryGmail *query1 = [GTLQueryGmail queryForUsersMessagesGet];
query1.identifier=mailID;
[self.service executeQuery:query1
delegate:self
didFinishSelector:@selector(displayResultWithTicketOfAttachment:finishedWithObject:error:)];
}
- (void)displayResultWithTicketOfAttachment:(GTLServiceTicket *)ticket
finishedWithObject:(GTLGmailListLabelsResponse *)labelsResponse
error:(NSError *)error {
NSDictionary *response1=labelsResponse.JSON;
NSDictionary *response2=[[[response1 valueForKey:@"payload"] valueForKey:@"parts"]objectAtIndex:1];
if ([[response2 valueForKey:@"mimeType"] isEqualToString:@"application/vnd.ms-excel"]) {
attachmentId=[[response2 valueForKey:@"body"]valueForKey:@"attachmentId"];
NSLog(@"%@",attachmentId); //Ex: ANGjdJ_Uw2o7G2Q16jfC4JSTwD2UIO6LuqDIJZvXFCft0q5ALYuiYfM2gPWG0dcty2n6ZkjnVWekIb_3e2_0TqSpctWNAABsfaSF2x2ktf9uHu63e3eIot_GFA9xgppmaRDyaJEL1V-gIvjfPRxgINK8xM0OuuwnVz2xzcCFckkwpK2XwzZG_QPGPvC2Be2bGKNJI8Ds3hGtqfHYeSWZjOjbsjBuxbUFjf1Mlp0TLol9LLAy2cjGZ_CUBQXzZhhWw9AtNHTU4jwhk4WizKRXbfuDvmRtAy1lPCnTKS6pLg
答案 0 :(得分:2)
你把Ids混淆了一下。
ggplot() +
geom_path(data = usa, aes(x = long, y = lat, group = group)) +
theme_general + geom_point(data = CombinedStudentsUSA1,
aes(x = Long, y = Lat, size = Number), color = "blue", shape=19, alpha=.5)+
scale_size_continuous(range = c(2, 4))
您在回复中获得的数据为Base64-encoded,并且通过替换所有&#34; +&#34;来确保网址安全。使用&#34; - &#34;,以及所有&#34; /&#34;用&#34; _&#34;。
只需将其转换回常规Base64数据并解码即可!在您的开发者工具中尝试此操作(按F12):
GTLQueryGmail *query2 = [GTLQueryGmail queryForUsersMessagesAttachmentsGet];
query2.id=attachmentId;
query2.messageId=mailID;
在代码中执行相同的步骤,您将获得原始格式的数据。