I have done Authentication using Google authentication API.How can I access Google task values into table view and proceed
NSString *googleapi = [NSString stringWithString: #"https://maps.googleapis.com/maps/api/place/search/xml?location=34.0522222,-118.2427778&radius=500&types=bank&sensor=false&key=Your_API_Key"];
NSURL *googlePlacesURL = [NSURL URLWithString:googleapi];
NSData *xmlData = [NSData dataWithContentsOfURL:googlePlacesURL];
For more >> Working with Google Places API in iPhone
Edited Addition...
NSString *usergoogleapi = [NSString stringWithString:#"User_API_Key"];// change this api according to user.
NSString *googleapi = [NSString stringWithFormat: #"https://maps.googleapis.com/maps/api/place/search/xml?location=34.0522222,-118.2427778&radius=500&types=bank&sensor=false&key=%#",usergoogleapi];
Hope, this will help you...
Related
I am looking for a way to get the app icon from the app id. Do you know how to do it? Please share the way. Thanks.
e.g
Instagram, where the id I'm looking for is: id389801252
https://itunes.apple.com/jp/app/instagram/id389801252?mt=8
I want to get this image:
(I composed this answer after 2 minutes of googling... It's just the matter of the correct keyword!)
This is possible using an undocumented documented API of the iTunes Store. It might change in the future, but it doesn't seem to have changed in the near past, so here you are...
NSString *idString = #"id389801252";
NSString *numericIDStr = [idString substringFromIndex:2]; // #"389801252"
NSString *urlStr = [NSString stringWithFormat:#"http://itunes.apple.com/lookup?id=%#", numericIDStr];
NSURL *url = [NSURL URLWithString:urlStr];
NSData *json = [NSData dataWithContentsOfURL:url];
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:json options:0 error:NULL];
NSArray *results = [dict objectForKey:#"results"];
NSDictionary *result = [results objectAtIndex:0];
NSString *imageUrlStr = [result objectForKey:#"artworkUrl100"]; // or 512, or 60
NSURL *artworkURL = [NSURL URLWithString:imageUrlStr];
NSData *imageData = [NSData dataWithContentsOfURL:artworkURL];
UIImage *artworkImage = [UIImage imageWithData:imageData];
Note that this performs two synchronous round-trips using the NSURL API, so you better wrap this in a backgorund thread for maximal user experience. Feed this program an ID string (idString in the code above) and in the end, artworkImage will contain a UIImage with the desired image.
Just for reference, you can use the app's bundle id too:
http://itunes.apple.com/lookup?bundleId=com.burbn.instagram
Not sure if this is at all relevant anymore, but Apple provides an iTunes Link Maker tool. If you use this tool to find your app, you'll also see where it shows an App Icon section. Click embed and grab the img link from there. One thing to note, I did end up playing with the url a bit to find the right size and format I needed (for instance you can get a jpg render instead of png or select an arbitrary size like 128x128)
I am trying to develop an travel application.I would like to submit the Airport code and get back the Country,City, along with the weather of that particular space.Is there an API out in the market that will help me in doing that???Or is there some other way I can do that?
Here's one for the city/country: http://airportcode.riobard.com/about
and this question has good info about weather: Weather API - Provides "About to..." Information?
Here's a sample piece of code that accepts the text from 'inputTextField' and outputs the location to 'outputLabel'
-(IBAction)getCity{
NSString *urlString = [NSString stringWithFormat:#"http://airportcode.riobard.com/airport/%#?fmt=json",self.inputTextField.text];
NSURL *url = [NSURL URLWithString:urlString];
NSString *response = [[NSString alloc] initWithContentsOfURL:url];
const char *convert = [response UTF8String];
NSString *responseString = [NSString stringWithUTF8String:convert];
NSDictionary *airport = [responseString JSONValue];
self.outputLabel.text=[airport objectForKey:#"location"];
}
How does one download or fetch a file using iOS?
I want to fetch a plist file from a server and open it within the app.
Does there need to be a php web client on the server or how would this be done, keeping security in mind to?
NSURL *address = [NSURL URLWithString:#"http://yourwebsite.com/file.plist"];
NSString *fileString = [NSString stringWithContentsOfURL:address];
with this You can fetch file content in a string.
NSURL *address = [NSURL URLWithString:#"http://yourwebsite.com/file.plist"];
NSString *fileString = [NSString stringWithContentsOfURL:address encoding:NSUTF8StringEncoding error:nil];
after fetching you can display this content in UITextView.
[youtextview setText:fileString];
I created an app which get the url of my youtube videos in the text field using GData Client Library. Now i want to shorten that url using bitly api.. But i don't have an idea about that.
if anybody done it before me, please tell me how you did it.
Thanks,
Chakradhar.
This is a quick and easy way of doing it.
You will need to register with bit.ly and obtain a login name and API key.
NSString *username = #"user";
NSString *apiKey = #"R_11111111111111";
NSString *url = #"yoururl.com";
NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://api.bit.ly/v3/shorten?login=%#&apikey=%#&longUrl=%#&format=txt", username, apiKey, url]] encoding:NSUTF8StringEncoding error:nil];
Here is an iOS wrapper for bit.ly api https://github.com/st3fan/iphone-bitly
This has worked well for me, and since it is a synchroeous request there is a slight delay to fetch the link so you may want to display a Progress HUD:
NSString *accessToken = YOUR_ACCESS_TOKEN;
NSString *url = YOUR_URL;
NSString *bitlyRequest = [NSString stringWithFormat:#"https://api-ssl.bitly.com/v3/shorten?access_token=%#&longUrl=%#",accessToken, url];
NSString *bitlyResponse = [NSString stringWithContentsOfURL:[NSURL URLWithString:bitlyRequest] encoding:NSUTF8StringEncoding error:nil];
NSData *data = [bitlyResponse dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *bitlyDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSString *bitlyUrl = bitlyDictionary[#"data"][#"url"];
I suggest you start with theri API documentation.
How can I concatenate an NSString URL? For example:
http://isomewebsite.com/username=[someuservariable]&password=[somevariable]
Try with below code.
NSString* myURLString = [NSString stringWithFormat:#"somewebsite.com/username=%#&password=%#", myUserName,myPassword];
NSURL *url = [NSURL URLWithString:myURLString];
Here is the blog tutorial will help you know more about Handling url authentication challenges accessing password protected servers
You can use the method stringWithFormat of NSString:
NSString *url = [NSString stringWithFormat:#"somewebsite.com/username=%#&password=%#", someuservariable, some variable];
Try this excellent post - URL encoding an NSString on iOS