IOS Facebook的图形API - 上传音频文件 [英] ios Facebook Graph API - post Audio file

查看:201
本文介绍了IOS Facebook的图形API - 上传音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是iOS中FB图形API发布在用户的墙。我要附加托管在其他地方的音频文件。作为附件似乎不再有效,我想OG:音频物业:

  SBJSON * jsonWriter = [[SBJSON新]自动释放];    * NSString的fileURL = [的NSString stringWithFormat:@http://site-addr.com/%@,@tst.mp3];    *的NSDictionary属性= [NSDictionary的dictionaryWithObjectsAndKeys:
                                fileURL,@OG:音频,
                                strText中,@OG:音频:标题
                                零];    * NSString的propStr = [jsonWriter stringWithObject:性能]
    *的NSMutableDictionary PARAMS = [的NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @消息文本,@消息,
                                   @玛莎,@名,
                                   @HTTP://addr/something.jpg,@图片报
                                   propStr,@属性,
                                   零];[Facebook的requestWithGraphPath:@我/饲料andParams:PARAMS andHttpMethod:@POSTandDelegate:个体经营];

不知怎的,我得到的是OG:音响......为文成一职。
我不知道如何发布音频文件作为球员进入后。


解决方案

   - (无效)postMeFeedButton $ P $ {pssed    *的NSMutableDictionary变量= [的NSMutableDictionary dictionaryWithCapacity:4];    [变量的setObject:@共享音频forKey:@消息];
    [变量的setObject:[的NSString stringWithFormat:@音频从XYZforKey:@名];
    [变量的setObject:@音频网址here.mp3forKey:@源];    FbGraphResponse * fb_graph_response = [fbGraph doGraphPost:@我/饲料withPostVars:变量];
    的NSLog(@postMeFeedButton pressed:%@,fb_graph_response.htmlResponse);
    //我们解析JSON
    SBJSON *解析器= [[SBJSON的alloc]初始化];
    *的NSDictionary = facebook_response [解析objectWithString:fb_graph_response.htmlResponse错误:无];
    [解析​​器释放];    //让我们保存的ID的Facebook给了我们,所以如果用户presses了删除/我/饲料按钮,我们可以将其删除
    self.feedPostId =(的NSString *)[facebook_response objectForKey:@ID];
    的NSLog(@feedPostId,%@,feedPostId);
    的NSLog(@现在登录到Facebook和看您的个人资料......);}

这将present嵌入式播放器中的音频内容。
希望它有帮助的人。
谢谢

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.

解决方案

-(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

这篇关于IOS Facebook的图形API - 上传音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆