Facebook 个人资料图片 url 未传入 NSURL
facebook profile picture url not passing in NSURL
我正在尝试传递格式中的个人资料图片 url
https://fbcdn-profile-a.akamaihd.net/hpe-ak-xtp1/v/t1.0-1/c1.0.720/p7720/1364291238051_6773172187152486924_n.jpg?oh=6fda2708e5c1a5de47263&oe=585DC8CF&__gda__=1482408d4fc8e65486e8e1c269af042
但是当我通过它时
NSString *fbpicurl = @"https://fbcdn-profile-a.akamaihd.net/hpe-ak-xtp1/v/t1.0-1/c1.0.720/p7720/1364291238051_6773172187152486924_n.jpg?oh=6fda2708e5c1a5de47263&oe=585DC8CF&__gda__=1482408d4fc8e65486e8e1c269af042";
NSString *post =[[NSString alloc] initWithFormat:@"profilepic=%@",fbpicurl];
NSURL *url=[NSURL URLWithString:@"http://URL.com"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
当我以这种方式通过时 url 没有完全通过它只是在 oh=6fda2708e5c1a5de47263
之后找到 &
的地方请帮助我如何通过完整的 [=21] =] 字符串.
首先对您的 url 字符串进行编码。
+ (NSString *) addPercentEscapesAndReplaceAmpersand: (NSString *) yourUrlString
{
NSString *encodedString = [yourUrlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
return [encodedString stringByReplacingOccurrencesOfString: @"&" withString: @"%20"];
}
然后使用 NSURL URLWithString
为 url 使用字符串
我正在尝试传递格式中的个人资料图片 url
https://fbcdn-profile-a.akamaihd.net/hpe-ak-xtp1/v/t1.0-1/c1.0.720/p7720/1364291238051_6773172187152486924_n.jpg?oh=6fda2708e5c1a5de47263&oe=585DC8CF&__gda__=1482408d4fc8e65486e8e1c269af042
但是当我通过它时
NSString *fbpicurl = @"https://fbcdn-profile-a.akamaihd.net/hpe-ak-xtp1/v/t1.0-1/c1.0.720/p7720/1364291238051_6773172187152486924_n.jpg?oh=6fda2708e5c1a5de47263&oe=585DC8CF&__gda__=1482408d4fc8e65486e8e1c269af042";
NSString *post =[[NSString alloc] initWithFormat:@"profilepic=%@",fbpicurl];
NSURL *url=[NSURL URLWithString:@"http://URL.com"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
当我以这种方式通过时 url 没有完全通过它只是在 oh=6fda2708e5c1a5de47263
之后找到 &
的地方请帮助我如何通过完整的 [=21] =] 字符串.
首先对您的 url 字符串进行编码。
+ (NSString *) addPercentEscapesAndReplaceAmpersand: (NSString *) yourUrlString
{
NSString *encodedString = [yourUrlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
return [encodedString stringByReplacingOccurrencesOfString: @"&" withString: @"%20"];
}
然后使用 NSURL URLWithString