How to get WOEID without using yahoo services? - ios

Is there any other alternative to get WOEID of a place, other than yahoo services? Is there any third party library which is free?

You can get it by making a query request using the city name you want and hitting yahoo service with code like this:
NSString *request = [NSString stringWithFormat:#"http://query.yahooapis.com/v1/public/yql?q=select * from geo.places where text=\"%#\"&format=xml", cityName];
NSString *encRequest = [request stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *URL = [NSURL URLWithString:encRequest];
I've put the complete example for this in github, but this is a solution just for testing purposes. You should use the official way (and pay if needed) for a commercial app.

Related

iOS dropbox sdk / core api - listing public folder contents without authorization

I've tried checking on stackoverflow and on the api docs, but couldn't find any info pertaining to this particular question.
What I'm trying to do is getting the public folder contents of a particular dropbox account (like the /metadata function of the api), without the need to authorize/link to dropbox.
I know "/metadata/link" allows you to get metadata of a particular link without user authorization, but I couldn't find a way to get regular metadata and file listing...
Actually it doesn't even need to be a public folder (as I've read recently that dropbox discourages developers regarding relying on public folders for apps), it can just as well be a regular folder through its shared link or anything of the kind...
I'm using api v1 (but can consider changing to v2 if this is impossible with v1), although I'm not even sure if this is at all possible.
Thank you!
For future reference, if anyone needs this as well, here's how I did it:
NSString *parameters = [NSString stringWithFormat:#"?link=%#&client_id=%#&client_secret=%#",fileUrl, appKey, appSecret];
NSString *sharedPath = [NSString stringWithFormat:#"%#/%#",#"https://api.dropbox.com/1/metadata/link", parameters];
NSURL *url = [NSURL URLWithString:sharedPath];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:10];
theRequest.timeoutInterval = 5.0;
theRequest.HTTPMethod = #"POST";
NSData * resData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];
Use NSJSONSerialization to parse resData and refer to the api documentation for json fields, and that's it.
For the sake of simplicity showing it here I used synchronous request, but it can just as easily be done with asynchronous connection delegates.

Use post request to receive LinkedIn user profile information in iOS

I am looking for a way to retrieve the profile information of a LinkedIn user by making a post request, I have read these two LinkedIn pages but it doesn't seem to explain much, or I couldn't understand much of it:
REST API LinkedIn
basic profile informations
I have seen these example on stackoverflow but I didn't understood to much:
http://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,email-address,formatted-name,phonetic-last-name,location:(country:(code)),industry,distance,current-status,current-share,network,skills,phone-numbers,date-of-birth,main-address,positions:(title),educations:(school-name,field-of-study,start-date,end-date,degree,activities))
I am only interested to retrieve the skills section the one that on the website appears as so:
There's a fantastic library for LinkedIn-iOS integration by Kirsten Jones, you can use that to make calls to the LinkedIn API. You need an access token to make calls.
https://github.com/PrincessPolymath/LinkedIn-OAuth-Sample-Client
Make calls like this:
NSURL *url = [NSURL URLWithString:#"http://api.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,formatted-name,phonetic-last-name,location:(country:(code)),industry,distance,current-status,current-share,network,skills,phone-numbers,date-of-birth,main-address,positions:(title),educations:(school-name,field-of-study,start-date,end-date,degree,activities))"]];
OAMutableURLRequest *request =
[[OAMutableURLRequest alloc] initWithURL:url
consumer:oAuthLoginView.consumer
token:oAuthLoginView.accessToken
callback:nil
signatureProvider:nil];
[request setValue:#"json" forHTTPHeaderField:#"x-li-format"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:#selector(profileApiCallResult:didFinish:)
didFailSelector:#selector(profileApiCallResult:didFail:)];
- (void)profileApiCallResult:(OAServiceTicket *)ticket didFinish:(NSData *)data
{
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSDictionary *profile = [responseBody objectFromJSONString];
if ( profile )
{
name.text = [[NSString alloc] initWithFormat:#"%# %#",
[profile objectForKey:#"firstName"], [profile objectForKey:#"lastName"]];
headline.text = [profile objectForKey:#"headline"];
.....and get skills and other user details
}
}
Use tool:https://apigee.com/console/linkedin
API to get the list of Skills:
https://api.linkedin.com/v1/people/~:(id,num-connections,skills)?format=json
I tried it in the Console tool and able to fetch the skills for my profile. I think the individual skill ID with above request should help you to get further information. Try it out.
If anyone is reading this answer, the LinkedIn API has limited access as of May 2015. You will need to apply to their Apply with LinkedIn program to access full profile fields including skills.
https://developer.linkedin.com/docs/fields
I have fair amount of experience working with the linkedIn API. It's been a little while, but hopefully this will set you on the right track.
To get profile information from a linked in user who is one of your connections you need a format like follows:
NSString *theRequest = [NSString stringWithFormat:#"https://api.linkedin.com/v1/people/id=abc123:(first-name,last-name,picture-url,location:(name))?oauth2_access_token=%#&format=json", accessToken];
This request will return the first name, last name, profile picture url, and location of the user with the id specified.
You can see a list of field types you can request by checking out linkedIn's documentation on their profile field descriptions here:
https://developer.linkedin.com/docs/fields
If you're wondering how to get the id of the user whose profile information you want request in the first place, you can make request for some basic info (including ids) of all your connections like this:
NSString *basicConnectionInfo = [NSString stringWithFormat:#"https://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name)?oauth2_access_token=%#&format=json", accessToken];
This request will give you the id, first name, and last name of all of your connections. After you've gotten the id of the person you want, you can make a request using the user's id (as shown in the first example).
Now for the slightly unfortunately news... If you followed the link provided above, you'll notice that the skills field is part of the "Member profile fields available to Apply with LinkedIn developers". I'm assuming you'll have to follow this link they provided: https://developer.linkedin.com/docs/apply-with-linkedin in order to access the skills member profile field.
I have not applied with LinkedIn. So, I haven't tested a call to the skills field. But, I'm guessing it'll be similar to the examples I've shown you. Hope this helps!

iOS: using Yahoo's BOSS search API to receive web results for my iPhone app. OAuth errors

I've searched up and down for a solution, but each one I found do not work and Yahoo's BOSS documentation is awful. It shows you how to send a request to the API but it clearly lacks all of the other required parameters that need to be included to fulfill OAuth.
My app is a search app. I'm using a TableViewController and UISearchBar to populate the table with web search results.
My table cells work fine and the table populates with fake results.
[Image unavailable because I need 10 reputation points... wow.]
However, BOSS integration is proving to be a headache and I'm unfamiliar with this type of web programming.
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSString *appid = #"{CONSUMER_KEY}"; // Provided by Yahoo
NSString *query = searchText;
NSString *address = #"http://boss.yahooapis.com/ysearch/web/v1/";
NSString *request = [NSString stringWithFormat:#"%#%#%#%#%#",address, query, #"?appid=", appid, #"&format=xml"];
// TEST URL: http://boss.yahooapis.com/ysearch/web/v1/gfdgfd?appid={CONSUMER_KEY}&format=xml
NSURL *URL = [NSURL URLWithString:request];
NSError *error;
NSString *XML = [NSString stringWithContentsOfURL:URL encoding:NSASCIIStringEncoding error:&error];
NSLog(#"%#", error);
{CONSUMER_KEY} is the long special key provided by Yahoo upon registering your app to use their service.
I was receiving all kinds of oauth errors but documentation online says that BOSS doesn't use OAuth.
If anyone knows how to set me in the right direction, that'd be fantastic. Thank you!

iOS url multiple statements

I have recently discovered that there is no way for me to access mysql with the pre defined iOS libraries.
So I have started making an app that has a web viewer (hidden) and will visit a url to pass the information to the database.
But I am having trouble making it so it visits a url that contains multiple variables from my objective c code my example is below.
NSURL *url = [[NSURL alloc] initWithString:#"http://webpageurl.com/updatelocation.php?friendsphonenumber=%#&yourphonenumber=%#&message=%#", _friendsPhoneNumber.text, _yourPhoneNumber.text, _message.text];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[self.WebView loadRequest:request];
This is what the url should come out looking like
http://webpageurl.com/updatelocation.php?friendsphonenumber=1112223333&yourphonenumber=1112223333&message=hioehfoi
But my code is returning a error and I am a little unsure why any and all help is greatly appreciated.

Couldn't get Google custom search results using JSON

I'm developing an application that makes use of Google custom search api as a feature. I added a new custom search and included some sites to search, I was able to do a search and get the results I need, but all of a sudden it stopped returning results. It returns an empty array instead. I didn't alter anything, but it looks like I have a limited number of queries, am I right?
Here's the line of code responsible for query a search word:
NSString *search = [NSString stringWithFormat:#"https://www.googleapis.com/customsearch/v1?start=1&ie=utf8&key=XXXXXX&cx=XXXXX&q=SEARHWORD&alt=json"];
url = [NSURL URLWithString:[search stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
NSURLConnection *searchConnection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
Then the normal steps of parsing the results.
if it was working fine, and then stopped all of a sudden, you may have hit the limit.
You can double check by copy-pasting
https://www.googleapis.com/customsearch/v1?start=1&ie=utf8&key=XXXXXX&cx=XXXXX&q=SEARHWORD&alt=json
in a browser and seeing the response

Resources