通过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
答案 0 :(得分:1)
对我来说,FB Video Upload工作正常,所以我把我的代码放在这里:
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];
}
答案 1 :(得分:0)
我的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];