ios Facebook Graph API - 发布音频文件

标签 ios facebook facebook-graph-api audio

我正在 iOS 中使用 FB Graph API 在用户墙上发布。我想附加在其他地方托管的音频文件。由于“附件”似乎不再有效,我正在尝试 og:audio 作为属性:

    SBJSON *jsonWriter = [[SBJSON new] autorelease];

    NSString *fileURL = [NSString stringWithFormat:@"http://site-addr.com/%@", @"tst.mp3"];

    NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
                                fileURL, @"og:audio",
                                strText, @"og:audio:title", 
                                nil];

    NSString *propStr = [jsonWriter stringWithObject:properties];


    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"message Text",@"message",
                                   @"Martha",@"name",
                                   @"http://addr/something.jpg", @"picture",
                                   propStr, @"properties",
                                   nil];          

[facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];

不知何故,我得到的只是“og:audio”....作为帖子中的文本。 我想知道如何将音频文件作为播放器发布到帖子中。

最佳答案

-(void)postMeFeedButtonPressed{

    NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:4];

    [variables setObject:@"Sharing Audio" forKey:@"message"];
    [variables setObject:[NSString stringWithFormat:@"Audio from xyz" forKey:@"name"];
    [variables setObject:@"Audio URL here.mp3" forKey:@"source"];



    FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"me/feed" withPostVars:variables];
    NSLog(@"postMeFeedButtonPressed:  %@", fb_graph_response.htmlResponse);


    //parse our json
    SBJSON *parser = [[SBJSON alloc] init];
    NSDictionary *facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil];   
    [parser release];

    //let's save the 'id' Facebook gives us so we can delete it if the user presses the 'delete /me/feed button'
    self.feedPostId = (NSString *)[facebook_response objectForKey:@"id"];
    NSLog(@"feedPostId, %@", feedPostId);
    NSLog(@"Now log into Facebook and look at your profile...");

}

这将在嵌入式播放器中呈现音频内容。 希望它对某人有帮助。 谢谢

关于ios Facebook Graph API - 发布音频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8301118/

相关文章:

ios - Swift 3.0 中不准确的 DispatchTime.now()

android - 我可以包含一个自动完成和跨平台(iOS/Android)的字符串文件吗?

ios - Facebook iOS SDK 'one-time' 授权

JavaScript 不遵循正确的工作流程

c# - 使用 facebook c# sdk V.6.x 我怎样才能获得用户是管理员的所有页面的列表?

objective-c - 在运行时更改 iOS 4 中应用程序的图标

iOS updateSearchResultsForSearchController 只调用一次

facebook - 基于 Open Graph iframe 的视频嵌入支持?

facebook - 对于 HTTPS 用户,共享的 Facebook 视频不会内嵌在墙帖中显示

javascript - Facebook Feed,在墙上张贴两张照片。 JavaScript SDK