Facebook图谱API:音频分享

5

我能使用Facebook图形API分享音频吗?

  • 我能像视频一样直接上传音频到Facebook服务器吗?
  • 我能在Facebook上分享音频链接并显示嵌入式播放器吗?

我尝试了这个解决方案iOS Facebook Graph API - post Audio file,但它没有按预期工作。

我尝试分享音频链接http://bit.ly/Ok4ZX6,但它在Facebook上像普通链接一样显示,而不是嵌入式播放器http://i.stack.imgur.com/Ld67c.png

编辑

我使用的代码:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:4];
[params setObject:text forKey:@"message"];
[params setObject:title forKey:@"name"];
[params setObject:fileUrl forKey:@"source"];
[facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];

也使用了这段代码:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:4];
NSString *attachment = [NSString stringWithFormat:@"{'media': [{'type': 'mp3', 'src': '%@', 'title': '%@'}], 'messgae': 'Messgae Messgae Messgae', 'name': 'Name Name Name', 'href': '%@'}",amazon_link, title, link];
[params setObject:attachment forKey:@"attachment"];
[params setObject:text forKey:@"message"];
[params setObject:@"stream.publish" forKey:@"method"];
[facebook requestWithParams:params andDelegate:self];

嘿,阿米特,你写道你能在Facebook上分享视频...你能告诉我你是怎么做到的吗? - Jean-Luc Godard
3个回答

2
您尝试了那个链接中的哪个解决方案?请发布您自己的代码。我也注意到您的音频链接无法使用,至少对我来说是这样的。
我认为正确的方法是使用图形API中的“source”字段,而不是“link”。
这是一个有关开发者参考的好页面: http://developers.facebook.com/docs/reference/api/post/
要使用图形API上传视频,您可以这样做。您还需要被授权发布流权限。
NSString * file = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mov"];
NSData * video = [NSData dataWithContentsOfFile:file];
NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
         @"title", @"title",
         @"description", @"description",
         video, @"video.mov",
         @"video/quicktime", @"contentType",
     nil];
[facebook requestWithGraphPath:@"me/videos"
                     andParams:dict
                 andHttpMethod:@"POST"
                   andDelegate:self];

我已经添加了相关代码...是的,那个链接不起作用。即使我尝试其他有效的链接,结果也是一样的。 - Amit Battan
我想要的是可以像上传视频一样直接在Facebook服务器上上传音频,或者可以分享音频链接并在Facebook上显示嵌入式播放器。 - Amit Battan
我能够在Facebook上上传视频。我的问题是关于音频帖子。 - Amit Battan

0

Soundcloud使用og:video标签来显示嵌入式播放器。视频标签接受SWF文件,因此可以加载交互式音频播放器小部件。尝试使用OG Debugger查看标签。

目前,这似乎是在共享内容时显示播放器的唯一策略。


虽然看起来他们正在开发一个更好的解决方案:https://developers.facebook.com/docs/opengraph/music/ - Tom Waddington

0

试试这样做...对我来说有效...

NSMutableDictionary *variables=[[NSMutableDictionary alloc]init];

//Posting audio file
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Dookudu" ofType:@"mp3"];
FbGraphFile *file=[[FbGraphFile alloc]initWithData:[NSData dataWithContentsOfFile:filePath]];
[variables setObject:file forKey:@"file"];

FbGraphResponse *response=[fbgraph doGraphPost:@"me/videos" withPostVars:variables];
NSLog(@"response %@",response.htmlResponse);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接