脸书图形API:音频共享



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

  • 我可以直接在Facebook服务器上上传音频,如视频吗?
  • 我可以在脸书上分享音频链接,它会在脸书上显示嵌入式播放器吗?

我已经尝试过这个解决方案 ios Facebook 图形 API - 发布音频文件 ,但它没有按预期工作

我尝试的是 http://bit.ly/Ok4ZX6 共享音频链接,但在Facebook上显示它,就像普通链接一样,而不是嵌入式播放器 https://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];

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

我认为正确的方法是在图形 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];

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

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

试试这样。它为我工作..

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

最新更新