5

Can I share audio using facebook graphic API

  • Can I directly upload audio on facebook server like video?
  • Can I share audio link on facebook and it will show embedded player on facebook?

I have tried this solution ios Facebook Graph API - post Audio file , but it doesn't work as expected

What I tried is to share audio link http://bit.ly/Ok4ZX6 but show it on facebook like a normal link not with embedded player https://i.stack.imgur.com/Ld67c.png

Edit

Code I have use :

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

Also used this code too :

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];
1
  • Hey Amit you wrote that you are able to share video in facebook ... can you tell me how are you doing this? Aug 5, 2012 at 17:23

3 Answers 3

2

What solution from that link did you try? Post your own code. I also noticed that your audio link doesn't work, atleast not for me.

I think the correct way is to use the "source" field in the graph api, not "link".

This is a good page on the developer reference: http://developers.facebook.com/docs/reference/api/post/


To upload a video using the graph API you can do this. You also need to be authorized to the publish_stream permission.

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];
3
  • I have add the code in question.. yes that link is not working. even I try other working link but same result. Jul 6, 2012 at 7:42
  • I want either Can directly upload audio on facebook server like video. OR can share audio link and it will show embedded player on facebook. Jul 6, 2012 at 7:46
  • I am able to upload the video on facebook.. my question here is regards Audio post Jul 9, 2012 at 4:59
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.

1
0

Try like this.. Its working for me..

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.