gpt4 book ai didi

ios - Facebook scores api with iOS5.1 - Can read scores...但不能发布

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:50:53 28 4
gpt4 key购买 nike

我是 iOS 开发的新手,我已经成功地集成了 facebook 登录等...但是我的问题是 Score api。我可以阅读乐谱,但我似乎无法发布它,我拥有 publish_actions 权限,并且正在取回有效的 access_token。不确定是什么问题,这是我的代码 -

NSString *accessTokenToUse = [NSString stringWithFormat:@"%@",[self.facebook accessToken] ];

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
//@"233", @"score",
accessTokenToUse, @"access_token",
nil];
NSMutableDictionary *paramsB = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"233", @"score",
accessTokenToUse, @"access_token",
nil];
NSLog(@"APP ACCESS TOKEN: %@",accessTokenToUse);

[self.facebook requestWithGraphPath:@"me/scores" andParams:paramsB andHttpMethod:@"POST" andDelegate:self];
[self.facebook requestWithGraphPath:@"APP_ID/scores" andParams:params andHttpMethod:@"GET" andDelegate:self];

***编辑 - 仍然无效

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"233", @"score",
@"[APP_ACCESS_TOKEN (omitted for stackoverflow)]", @"access_token", nil];
[self.facebook requestWithGraphPath:@"/[userID]/scores" andParams:params andHttpMethod:@"POST" andDelegate:self];

编辑 - 已解决

所以基本上我传递了正确的 token ,但是 facebook sdk 在 Facebook.m 中将其覆盖为用户的访问 token 。所以修复很简单——每当我需要传递应用程序的 token 时,我只需添加另一个参数p>

- (FBRequest*)openUrl:(NSString *)url
params:(NSMutableDictionary *)params
httpMethod:(NSString *)httpMethod
delegate:(id<FBRequestDelegate>)delegate {

NSLog(@"PARAMS BFORE: %@ ", params);
[params setValue:@"json" forKey:@"format"];
[params setValue:kSDK forKey:@"sdk"];
[params setValue:kSDKVersion forKey:@"sdk_version"];

if ([self isSessionValid]) {
if ([params objectForKey:@"useAppToken"] == nil || [params objectForKey:@"useAppToken"] == @"no") {
[params setValue:self.accessToken forKey:@"access_token"];
}

}
NSLog(@"PARAMS AFTER: %@ ", params);
[self extendAccessTokenIfNeeded];

FBRequest* _request = [FBRequest getRequestWithParams:params
httpMethod:httpMethod
delegate:delegate
requestURL:url];
[_requests addObject:_request];
[_request addObserver:self forKeyPath:requestFinishedKeyPath options:0 context:finishedContext];
[_request connect];
return _request;

请务必在此处注释掉 NSLogs...:)

最佳答案

只能使用应用程序 access_token 发布乐谱,而不能为用户发布乐谱(您可能正在使用它,可以阅读乐谱,但不允许您发布它们)。

引用 Scores documentaion :

Create or update a score for a user
You can post a score or a user by issuing an HTTP POST request to /USER_ID/scores with the app access_token as long as you have the publish_actions permission.

关于ios - Facebook scores api with iOS5.1 - Can read scores...但不能发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10993453/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com