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
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];