我有一个关于Google Plus iOS SDK的问题。有没有办法在不必使用GPPShareBuilder
的情况下共享照片和/或消息?我需要制作一个自定义界面来做到这一点,但找不到任何功能或解决方案来制作一个简单的共享界面。
还行。我已经在开发者控制台中启用了 Google Plus 域 API。并尝试通过媒体上传照片:插入。这是一个代码:
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"
}
}
我的代码出了什么问题?
当然,谷歌在https://plus.google.com/share
提供了一个共享端点。 此终结点采用两个参数:url
用于映像,hl
用于语言代码。
您可以将使用 OpenGraph 标记(例如 og:title
)将图片发布到 Google+ 时显示的元数据调整到托管图片的网页上。
有关OpenGraph标签的更多信息可以在这个问题中找到:Google+共享网址:它使用哪些参数?