2011-11-28 117 views
2

我在iOS中使用FB Graph API在用户墙上发帖。我想附上其他地方托管的音频文件。作为“附件”似乎不再有效,我想OG:音频物业:ios Facebook Graph API - 发布音频文件

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:音响” ......为文成职。 我不知道如何将音频文件作为播放器发布到帖子中。

回答

3
-(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..."); 

} 

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

+0

嗨我已经使用此代码但嵌入式播放器不起作用。我的音频文件URL是http://bit.ly/Ok4ZX6。 。 。并在Facebook上显示,如http://i.stack.imgur.com/Ld67c.png –