【发布时间】:2023-03-17 07:58:02
【问题描述】:
我有一个关于Google Plus iOS SDK 的问题。有什么方法可以分享照片和/或消息而无需使用GPPShareBuilder?我需要制作一个自定义界面来做到这一点,但找不到任何功能或解决方案来制作一个简单的共享界面。
好的。我已经在开发者控制台中启用了 Google Plus 域 API。并尝试通过Media:insert 上传照片。这是一个代码:
NSError *error;
NSDictionary *body = @{ @"mediaURL" : photoURL.description };
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:body options:NSJSONWritingPrettyPrinted error:&error];
NSURL *apiURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.googleapis.com/upload/plusDomains/v1/people/me/media/cloud?access_token=%@", [self accessToken]]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:apiURL];
request.HTTPMethod = @"POST";
request.HTTPBody = jsonData;
[request addValue:@"image/JPG" forHTTPHeaderField:@"Content-Type"];
NSOperationQueue *queue= [NSOperationQueue mainQueue];
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)
{
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@", responseString);
}];
我总是得到下一个回复:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
我的代码有什么问题?
【问题讨论】:
标签: ios objective-c sdk google-plus