【问题标题】:iOS Google Plus sharing with custom GUIiOS Google Plus 与自定义 GUI 共享
【发布时间】: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


    【解决方案1】:

    当然,Google 在https://plus.google.com/share 提供了一个share 端点。此端点接受两个参数:url 用于您的图像,hl 用于您的language code

    您可以使用 OpenGraph 标记(例如 og:title)将您的图片发布到 Google+ 时显示的元数据调整到托管您图片的网页。

    更多关于 OpenGraph 标签可以在这个问题中找到:Google+ share url: what parameters does it use?

    【讨论】:

      猜你喜欢
      • 2015-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-03
      • 1970-01-01
      • 2015-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多