“签名不正确”来自 FBVideoUpload 请求

发布于 2024-11-03 08:35:02 字数 2486 浏览 1 评论 0原文

通过 FBConnect 上传视频时,我收到“签名不正确”错误(版本位于 https:// /github.com/zoul/facebook-ios-sdk/)。见下文。

有什么想法如何调试这个吗?

是否有通过 FBConnect 上传视频的工作示例?

任何建议将不胜感激。

代码:

NSArray *permissions = [NSArray arrayWithObjects:@"publish_stream", @"offline_access",nil];
_facebook.forceOldStyleAuth = TRUE;
[_facebook authorize:APP_ID permissions:permissions delegate:_facebookDelegate];

...

NSString *path = [[NSBundle mainBundle] pathForResource:@"dreamall" ofType:@"m4v" inDirectory:@"/"];
NSURL *url = [NSURL fileURLWithPath:path];
FBVideoUpload *upload = [[FBVideoUpload alloc] init];
upload.accessToken = _facebook.accessToken;
upload.apiKey = API_KEY;
upload.appSecret = SECRET;
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"test", @"title",
                               @"upload testing", @"description",
                               nil];
[upload startUploadWithURL:url params:params delegate:self];

响应:

<error_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
  <error_code>104</error_code>
  <error_msg>Incorrect signature</error_msg>
  <request_args list="true">
    <arg>
      <key>description</key>
      <value>upload testing</value>
    </arg>
    <arg>
      <key>v</key>
      <value>1.0</value>
    </arg>
    <arg>
      <key>api_key</key>
      <value>...</value>
    </arg>
    <arg>
      <key>method</key>
      <value>facebook.video.upload</value>
    </arg>
    <arg>
      <key>session_key</key>
      <value>41ab9717c61b70a34a8e48d4.3-100000419172530</value>
    </arg>
    <arg>
      <key>sig</key>
      <value>bca612d495400136f1847f2bc6907525</value>
    </arg>
    <arg>
      <key>title</key>
      <value>test</value>
    </arg>
  </request_args>
</error_response>
í£|<€_Y†gÊˇ¯ZÓzì&Àle4:∫Ù6V-Fn#vÂΩ'‚¥gƒ˙Y†ˇOáeyœn,≠ˇŒX≤Ÿ˘¡¬6G˛éÊ]÷FùC¯7˘JêÁW˙∫nÂfi${(;∑.L‰¯õßÏAüˆ—6Û{ˆhu|ûfi± •ìn£hfiÇç£÷¥GÃ…˛Ü·B:up

I'm getting an "Incorrect signature" error when uploading a video through FBConnect (version at https://github.com/zoul/facebook-ios-sdk/). See below.

Any ideas how to debug this?

Is there a working example for uploading a video through FBConnect?

Any suggestions would be appreciated.

The code:

NSArray *permissions = [NSArray arrayWithObjects:@"publish_stream", @"offline_access",nil];
_facebook.forceOldStyleAuth = TRUE;
[_facebook authorize:APP_ID permissions:permissions delegate:_facebookDelegate];

...

NSString *path = [[NSBundle mainBundle] pathForResource:@"dreamall" ofType:@"m4v" inDirectory:@"/"];
NSURL *url = [NSURL fileURLWithPath:path];
FBVideoUpload *upload = [[FBVideoUpload alloc] init];
upload.accessToken = _facebook.accessToken;
upload.apiKey = API_KEY;
upload.appSecret = SECRET;
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"test", @"title",
                               @"upload testing", @"description",
                               nil];
[upload startUploadWithURL:url params:params delegate:self];

The response:

<error_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
  <error_code>104</error_code>
  <error_msg>Incorrect signature</error_msg>
  <request_args list="true">
    <arg>
      <key>description</key>
      <value>upload testing</value>
    </arg>
    <arg>
      <key>v</key>
      <value>1.0</value>
    </arg>
    <arg>
      <key>api_key</key>
      <value>...</value>
    </arg>
    <arg>
      <key>method</key>
      <value>facebook.video.upload</value>
    </arg>
    <arg>
      <key>session_key</key>
      <value>41ab9717c61b70a34a8e48d4.3-100000419172530</value>
    </arg>
    <arg>
      <key>sig</key>
      <value>bca612d495400136f1847f2bc6907525</value>
    </arg>
    <arg>
      <key>title</key>
      <value>test</value>
    </arg>
  </request_args>
</error_response>
í£|<€_Y†gÊˇ¯ZÓzì&Àle4:∫Ù6V-Fn#vÂΩ'‚¥gƒ˙Y†ˇOáeyœn,≠ˇŒX≤Ÿ˘¡¬6G˛éÊ]÷FùC¯7˘JêÁW˙∫nÂfi${(;∑.L‰¯õßÏAüˆ—6Û{ˆhu|ûfi± •ìn£hfiÇç£÷¥GÃ…˛Ü·B:up

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请远离我 2024-11-10 08:35:02

对我来说 FBVideoUpload 工作正常,所以我把我的代码放在这里:

m_Facebook = [[Facebook alloc] init];
m_FacebookUploader = [[FBVideoUpload alloc]init]; 
NSArray *permissions =  [NSArray arrayWithObjects:@"publish_stream", @"offline_access",nil];
m_Facebook.forceOldStyleAuth = YES;
[m_Facebook authorize:APP_ID permissions:permissions delegate:self];

在 Facebook 委托方法中

- (void)fbDidLogin
{
    NSURL *movieURL = [NSURL fileURLWithPath:m_MoviePath];

    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"Look at my funny video !", @"title",
                            [@"A message" objectForKey:@"message"], @"description",
                            nil];

    [m_FacebookUploader setApiKey:APP_ID];
    [m_FacebookUploader setAccessToken:m_Facebook.accessToken];
    [m_FacebookUploader setAppSecret:APP_SECRET];
    [m_FacebookUploader startUploadWithURL:movieURL params:params delegate:self];

}

For me FBVideoUpload works fine so I put my code here :

m_Facebook = [[Facebook alloc] init];
m_FacebookUploader = [[FBVideoUpload alloc]init]; 
NSArray *permissions =  [NSArray arrayWithObjects:@"publish_stream", @"offline_access",nil];
m_Facebook.forceOldStyleAuth = YES;
[m_Facebook authorize:APP_ID permissions:permissions delegate:self];

In Facebook delegate methods

- (void)fbDidLogin
{
    NSURL *movieURL = [NSURL fileURLWithPath:m_MoviePath];

    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"Look at my funny video !", @"title",
                            [@"A message" objectForKey:@"message"], @"description",
                            nil];

    [m_FacebookUploader setApiKey:APP_ID];
    [m_FacebookUploader setAccessToken:m_Facebook.accessToken];
    [m_FacebookUploader setAppSecret:APP_SECRET];
    [m_FacebookUploader startUploadWithURL:movieURL params:params delegate:self];

}
残月升风 2024-11-10 08:35:02

我的 Facebook 应用程序未设置为“桌面”模式。这就是身份验证不起作用的原因。请参阅:

http://code.google.com/p/facebook-java -api/wiki/DesktopMode

不幸的是,他们从 Facebook 的开发者网站中删除了此选项,因此不可能让当前版本的 FBVideoUpload 与新应用程序一起使用。

我已修改 FBVideoUpload 以使用新的 Graph API 而不是旧的 REST API。见下文。我将与 FBVideoUpload 的开发人员联系。

//static NSString *const kAPIURL = @"http://api-video.facebook.com/restserver.php";
static NSString *const kAPIURL = @"https://graph-video.facebook.com/me/videos";

...

/*
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:userParams];
[params setObject:@"1.0" forKey:@"v"];
[params setObject:@"facebook.video.upload" forKey:@"method"];
[params setObject:[self sessionID] forKey:@"session_key"];
[params setObject:apiKey forKey:@"api_key"];
[params setObject:[self signatureForParams:params] forKey:@"sig"];
[params setObject:[NSData dataWithContentsOfURL:movieURL] forKey:[movieURL lastPathComponent]];
[[FBRequest getRequestWithParams:params httpMethod:@"POST" delegate:delegate requestURL:kAPIURL] connect];
*/

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:userParams];
[params setObject:accessToken forKey:@"access_token"];
[params setObject:[NSData dataWithContentsOfURL:movieURL] forKey:[movieURL lastPathComponent]];
[FBRequest getRequestWithParams:params httpMethod:@"POST" delegate:delegate requestURL:kAPIURL];

My facebook app was not set to "Desktop" mode. That's why the authentication didn't work. See:

http://code.google.com/p/facebook-java-api/wiki/DesktopMode

Unfortunately, they removed this option from Facebook's developer site so it's not possible to get the current version of FBVideoUpload working with a new app.

I've modified FBVideoUpload to use the new Graph API instead of the old REST API. See below. I'll get in touch with the developer of FBVideoUpload.

//static NSString *const kAPIURL = @"http://api-video.facebook.com/restserver.php";
static NSString *const kAPIURL = @"https://graph-video.facebook.com/me/videos";

...

/*
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:userParams];
[params setObject:@"1.0" forKey:@"v"];
[params setObject:@"facebook.video.upload" forKey:@"method"];
[params setObject:[self sessionID] forKey:@"session_key"];
[params setObject:apiKey forKey:@"api_key"];
[params setObject:[self signatureForParams:params] forKey:@"sig"];
[params setObject:[NSData dataWithContentsOfURL:movieURL] forKey:[movieURL lastPathComponent]];
[[FBRequest getRequestWithParams:params httpMethod:@"POST" delegate:delegate requestURL:kAPIURL] connect];
*/

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:userParams];
[params setObject:accessToken forKey:@"access_token"];
[params setObject:[NSData dataWithContentsOfURL:movieURL] forKey:[movieURL lastPathComponent]];
[FBRequest getRequestWithParams:params httpMethod:@"POST" delegate:delegate requestURL:kAPIURL];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文