I'm integrating some Twitter functions on my app. So basically what i want to do is to retrieve tweets based on some keywords (#hashtags) and from those extract if present pictures and present them to the user.
The problem is that on "GET Search" query such as "http://search.twitter.com/search.json?q=Twitter%20API&result_type=mixed&count=5" entities are not supported so I'm wondering how can I achieve my task.
I thought to get all the tweets with that query and then for each tweet do this call "GET statuses/show/:id" so i can get the entities for each tweet- get the link in the tweet text - and then make another call to a service where tweet pictures are stored and shared but it seems inefficient, it needs a lot of connection.
Just % escape the #. In a URL %23 is a #.
This query will look for tweets tagged #iphone.
http://search.twitter.com/search.json?q=%23iphone&result_type=mixed&count=5
To escape the string do this
NSString url = #"url with #hashtag";
NSString *escapedString = [url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
That will replace the # with %23.
At that time Twitter Search API didn't support entities, now it works properly
Related
I've uploaded about 40k photos using the Google Photos uploader tool, and now I'm trying to get a list of those photos using the Picasa Web Albums Data API (as there is no separate Google Photos API that I'm aware of).
So far, it appears impossible to get a complete list of all of the photos because you can list only 1000 photos at a time and then use the start-index parameter to do paging, but the server returns an error once you use a start-index above 11000. With a start-index of 11000 this occurs:
gdata.photos.service.GooglePhotosException: (500, 'Internal Server Error', 'Deprecated offset is too large for a stream ID query. Please switch to using resume tokens.')
(I'm using Python, but have confirmed that the error is independent of the language library)
I'd be happy to switch to using "resume tokens" like the error indicates... except that they are not mentioned in any documentation that I could find.
This is an authenticated request and the URL I'm using looks like this:
https://picasaweb.google.com/data/feed/api/user/[myUserID]/albumid/[myAlbumID]?kind=photo&max-results=1000&start-index=11000
Can anyone show me an example request using resume tokens or point me to documentation on them? Or, if anyone knows of some other way to get a complete list of all of the photos in a large album, that'd be great too. Thanks!
EDIT: the problem happens in any language, but in Python you can reproduce it consistently with:
startIndex = 1
while 1:
print '(fetching more photos)'
photos = client.GetFeed(ALBUM_URL, limit=1000, start_index=startIndex)
for photo in photos.entry:
print 'startIndex:', startIndex
startIndex += 1
where ALBUM_URL is like the URL I listed above and client is an authenticated instance of gdata.photos.service.PhotosService.
I'm working on a project, and I'm completely stuck.
I get the user's location using CLLocation and am able to get the place name using CLGeocoder, and using this I've constructed a URL to search the Google Places Web API.
My question is, how can I actually complete the search and return the top place result's phone number? Any help would be much appreciated!
let url: URL = URL(fileURLWithPath: "https://maps.googleapis.com/maps/api/place/textsearch/json?query=taxi+" + placeMark.locality!+"&key=" + self.GAPIKEY)
This is the URL I've come up in case that helps
The first thing you need to do is an HTTP GET on the URL to get the API results. Consult the following SO question for various ways to do that:
How to make an HTTP request in Swift?
The data returned will be a JSON document in the format described in the Google Places API Docs. Look for the formatted_phone_number and/or international_phone_number fields. See Working with JSON in Swift for how to parse the JSON string.
I am developing an iPhone application that is using an API to find recipes from http://www.recipepuppy.com/about/api/.
There are three parameters that must be put into return results. There are i,q, and p, Where i are the ingredients, q in a normal search query and p is the page #. I am able to specifically add these parameters and then load the results into a table view in Xcode.
I also want to implement a search that allows the users to search for recipes based on whatever they feel like and return the results. Could someone point me in the correct direction on how to do this. I know I will have to take what ever the user inputs and place it into a string but how do I implement that string into the parameters of the URL?
To answer your question:
I know I will have to take what ever the user inputs and place it into a string but how do I implement that string into the parameters of the URL?
You can use the stringWithFormat method of NSString. For example:
NSString *ingredients = #"ingredients";
NSString *query = #"soups";
NSString *page = #"1";
NSString *url = [NSString stringWithFormat:#"http://www.recipepuppy.com/api/?i=%#&q=%#&p=%#",ingredients,query,page];
Before using this URL, it's recommended that you URL encode it.
NSString *encodedURL = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
Now that you have your URL, just start a connection to the web (NSURLConnection, AFNetworking, the choice is yours), parse the data returned, and load that into an array to display in the table view.
To build a solid app that involves JSON communication over the network, you can use the JSONModel library. It provides you with data models, and takes care of sending and receiving JSON forth and back to your API service.
You can have a look at the GitHub page:
https://github.com/icanzilb/JSONModel/
Or also to this example on how to use the YouTube JSON API with JSONModel:
http://www.touch-code-magazine.com/how-to-make-a-youtube-app-using-mgbox-and-jsonmodel/
On the GitHub page there are more code samples. Good luck :)
(Disclosure: I'm JSONModel's author)
I'd use AFNetworking for all your network requests:
https://github.com/AFNetworking/AFNetworking
To make the request just construct an NSString and send it off
[NSString stringWithFormat:#"http://www.recipepuppy.com/api/?i=%#&q=%#&p=%d", self.ingredients, self.query, self.page]
Facebook supports getting the number of comments on each url by using the following:
<fb:comments-count data-href="http://example-url.com"/></fb:comments-count>
The problem with this method is that it's working on the user-side and thus the result cannot be stored into SQL.
I'm looking for a method which can run server-side, able to be executed by CRON.
This can be easily achieved with simple FQL query:
SELECT commentsbox_count FROM link_stat WHERE url = "http://example-url.com"
To get this with Graph API use:
http://graph.facebook.com/fql?q=YOUR_QUERY
You would need to use the Graph API for this. You can access a JSON-encoded array of a URLs comments by going to, https://graph.facebook.com/comments/?ids={YOUR_URL}.
If you were using PHP, you could use file_get_contents() to fetch this URL, decode the JSON array and then use count() to get the number of comments. I don't believe that the comments end point is secured by OAuth so you shouldn't need to worry about that.
There are a bunch of tutorials online about how to use xmlparsers or what not to bring an entire twitter feed into a UITableView. Thats not what I need. I only want ONE tweet. The most recent twitter update.
So, would some of you geniuses please show me in detail how to get my last (most recent) TWEET into an NSString in my iPhone app?
In short: exactly the same as all those tutorials that you've read except you pass the count parameter to the statuses/user_timeline REST method.
Ohh, this is complicated, not so easy, I show you the steps:
Make the request to the api (synchronous or asynchonous)
Handle the Authentication Challenge for authenticated request
Get the data, call the parse method of the parser
Handle the delegation methods of the nsxmlparser
Manually handle the DidStartElement, DidFoundCharacters, DidEndElement to get the first status you want, assign the string value to a variable when it founds the characters.
That's all you need to do ;)
Good luck.