Twitter有一个很好的功能,允许您使用以下格式预加载状态消息:
http://twitter.com/?status=@HelloWorld Hello World
Run Code Online (Sandbox Code Playgroud)
或者:
http://twitter.com/?status=%40HelloWorld%20Hello%20World
Run Code Online (Sandbox Code Playgroud)
我正在尝试在我的iPhone应用程序中添加一个按钮,该按钮将打开Safari以上预先填充的推文.
但是我遇到了百分号被双重逃逸的问题.
这是我尝试过的代码:
NSString* urlText = @"http://www.twitter.com/home?status=@HelloWorld";
NSURL *url = [NSURL URLWithString: urlText];
if (![[UIApplication sharedApplication] openURL:(NSURL*)url])
NSLog(@"%@%@",@"Failed to open url:",[url description]);
Run Code Online (Sandbox Code Playgroud)
此代码的作用类似于魅力和输出:
http://twitter.com/?status=%40HelloWorld
Run Code Online (Sandbox Code Playgroud)
NSString* urlText = @"http://www.twitter.com/home?status=@HelloWorld Hello World";
NSURL *url = [NSURL URLWithString: urlText];
if (![[UIApplication sharedApplication] openURL:(NSURL*)url])
NSLog(@"%@%@",@"Failed to open url:",[url description]);
Run Code Online (Sandbox Code Playgroud)
这会创建一个null NSURL.我只能假设因为URLWithString不接受带有空格的文本.
所以我尝试了这段代码:
NSString* urlText = @"http://www.twitter.com/home?status=@HelloWorld%20Hello%20World";
NSURL *url = [NSURL URLWithString: urlText];
if (![[UIApplication sharedApplication] openURL:(NSURL*)url])
NSLog(@"%@%@",@"Failed to open url:",[url description]);
Run Code Online (Sandbox Code Playgroud)
但是,这会创建URL:
http://twitter.com/?status=%40HelloWorld%2520Hello%2520World
Run Code Online (Sandbox Code Playgroud)
所以我已经逃过了我的百分号%,这当然不是我想要的.
当然人们一直在谈论使用函数:stringByAddingPercentEscapesUsingEncoding
所以我写了这段代码: …
旧的REST API中的一个非常有用的调用是Friends.getAppUsers.此调用将返回正在使用应用程序的所有朋友.遗憾的是,这不在Open Graph API中.关于它有一个很好的Stack Overflow帖子,Facebook'Friends.getAppUsers'使用Graph API.
但是,可以使用Graph API进行FQL调用,如图API API资源管理器中所示.
我想也许我可以使用C#SDK进行以下调用:
fb.GetAsync("fql/?q=SELECT uid,username, is_app_user FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user=1");
Run Code Online (Sandbox Code Playgroud)
但是,这返回了一个错误.有没有办法解决GetAppUsers使用现有C#SDK 缺少呼叫的问题?