我已经在FBConnect
,
但我想用iOS提供的框架来做,即Social.framework
。
我已经提到this reference了, 但它给我错误:
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
如果您对此有任何参考或任何新方法,请帮助我。
谢谢&的问候,
詹尼弗
答案 0 :(得分:1)
最后,我可以使用SOCIAL
框架在Facebook上发布视频。
以下是它的方式:
1)确保用户已登录FaceBook帐户。
然后,
-(IBAction)sharewithFacebook:(id)sender{
__block ACAccount * facebookAccount;
ACAccountStore* accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray *accounts = [accountStore
accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
NSURL *videourl = [NSURL URLWithString:@"https://graph.facebook.com/me/videos"];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"YourVideoName" ofType:@"mp4"];
NSURL *pathURL = [[NSURL alloc]initFileURLWithPath:filePath isDirectory:NO];
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSDictionary *params = @{
@"title": @"Uploaded from my app",
@"description": @"https://github.com/Vishaliphone"
};
SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:videourl
parameters:params];
[uploadRequest addMultipartData:videoData
withName:@"source"
type:@"video/quicktime"
filename:[pathURL absoluteString]];
uploadRequest.account = facebookAccount;
[uploadRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
if(error){
NSLog(@"Error %@", error.localizedDescription);
}else
NSLog(@"%@", responseString);
}];
}
希望它能帮助他人。
感谢。
答案 1 :(得分:0)
您需要将访问令牌设置为能够获取数据或代表用户执行操作。请确保您的访问令牌处于活动状态。