简体   繁体   English

邮政中的非标准网址

[英]Non standard URLs in Post

I'm working on an iPhone app that shares data via a custom url scheme. 我正在开发一个通过自定义URL方案共享数据的iPhone应用程序。 This is working well in email, but I'm having difficulty getting this functionality in Facebook. 这在电子邮件中效果很好,但是我很难在Facebook中获得此功能。

I would like to post a link with a callback to my app using my custom url scheme. 我想使用自定义网址方案将带有回调的链接发布到我的应用程序。 Basically, I'd like a link that opens the app, if you're running on an iOS device with the app installed. 基本上,如果您在安装了该应用程序的iOS设备上运行,那么我希望有一个打开该应用程序的链接。

I'm attempting to do this using properties in a feed dialog, but on calling the dialog I get the error: The post's action links must be valid URLs... It appears that the API does not allow non-standard urls in the properties based on this - is there another way to do this? 我试图在Feed对话框中使用属性来执行此操作,但是在调用对话框时出现错误:帖子的操作链接必须是有效的URL ...看来,API不允许属性中使用非标准的url基于此-还有另一种方法吗?

SBJSON *jsonWriter = [SBJSON new];
NSDictionary *propertyvalue = [NSDictionary dictionaryWithObjectsAndKeys:@"Final Count", @"text", @"finalcount://somecustomstuffhere", @"href", nil];
NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:propertyvalue, @"Import ", nil];
NSString *finalproperties = [jsonWriter stringWithObject:properties];
NSString *finalactions = [jsonWriter stringWithObject:actions];            
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       kAppId, @"app_id",
                                       @"http://itunes.apple.com/us/app/final-count/id532992913?ls=1&mt=8", @"link",
                                       @"http://southwestgecko.com/wp-content/uploads/2012/05/PrimaryIcon@2x.png", @"picture",
                                       @"Final Count", @"name",
                                       @"caption", @"caption",
                                       @"description", @"description",
                                       finalproperties, @"properties",
                                       nil];
[facebook dialog:@"feed" andParams:params andDelegate:self];

This is how I ended up doing it: 这就是我最终这样做的方式:

I took advantage of the fact that my WordPress based web site will ignore anything after the normal URL, and packed in all the callback data there. 我利用了一个事实,即基于WordPress的网站将忽略普通URL之后的所有内容,并将所有回调数据打包在其中。 The Facebook app is smart enough to forward the full URL string onto the app, and my app is smart enough to ignore the first part of the URL that belongs to the WordPress web site. Facebook应用程序足够聪明,可以将完整的URL字符串转发到应用程序上,而我的应用程序足够聪明,可以忽略属于WordPress网站的URL的第一部分。

This is the link I put into the Facebook post: 这是我在Facebook帖子中添加的链接:

link = [NSString stringWithFormat:@"http://southwestgecko.com/?page_id=%i%@",timer.link, [self generateURLFromTimer:timer]];

where the [self generateURLFromTimer:timer] part generates the callback information. [self generateURLFromTimer:timer]部分在其中生成回调信息。 This gets put into the dictionary params from the original question under the key @"link". 这将从原始问题放在键“链接”下的字典参数中。 When a URL gets passed into the app, I simply parse out the part pointing to the web site and process the rest as a callback (which in this case includes all the timer information needed to import the timer into my app). 当URL传递到应用程序时,我只需解析指向网站的部分并将其余部分作为回调处理(在这种情况下,该部分包括将计时器导入我的应用程序所需的所有计时器信息)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM