5

我可以使用 facebook 图形 API 共享音频吗

  • 我可以像视频一样直接在 Facebook 服务器上上传音频吗?
  • 我可以在 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];
4

3 回答 3

2

您尝试了该链接的什么解决方案?发布您自己的代码。我还注意到您的音频链接不起作用,至少对我来说不是。

我认为正确的方法是使用图形 api 中的“源”字段,而不是“链接”。

这是开发人员参考的一个很好的页面:http: //developers.facebook.com/docs/reference/api/post/


要使用图形 API 上传视频,您可以这样做。您还需要获得 publish_stream 权限的授权。

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];
于 2012-07-05T19:28:31.017 回答
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);
于 2013-10-18T13:07:37.260 回答
0

Soundcloud use og:video tags to show the embedded player. The video tags accept SWF files, so it's possible to load up an interactive audio player widget. Try using the OG Debugger to see the tags.

Currently, this seems like the only strategy to show a player when content is shared.

于 2012-07-13T16:20:17.513 回答