Martha
Martha

Reputation: 1080

ios Facebook Graph API - post Audio file

I'm using FB Graph API in iOS to post at user's wall. I want to attach an audio file hosted somewhere else. As "attachment" seems not valid anymore, I'm trying og:audio as property:

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

Somehow, all I get is "og:audio".... as text into the post. I wonder how to post the audio file as a player into the post.

Upvotes: 2

Views: 1847

Answers (1)

Vasif Nagarwala
Vasif Nagarwala

Reputation: 46

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

}

This will present the audio content in embedded player. Hope its helpful to someone. Thanks

Upvotes: 3

Related Questions