Vix Hunk
Vix Hunk

Reputation: 323

facebook profile picture url not passing in NSURL

i am trying to pass profile pic url which is in the formate

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

but when i pass it like

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

when i pass it this way url do not pass completely it just cut of where if founds & right after oh=6fda2708e5c1a5de47263 please help me how can i pass complete url string.

Upvotes: 0

Views: 61

Answers (1)

Sangram Shivankar
Sangram Shivankar

Reputation: 3573

First encode your url string.

 + (NSString *) addPercentEscapesAndReplaceAmpersand: (NSString *) yourUrlString
    {
        NSString *encodedString = [yourUrlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; 
        return [encodedString stringByReplacingOccurrencesOfString: @"&" withString: @"%20"];
    }

Then used string for url by using NSURL URLWithString

Upvotes: 1

Related Questions