I want to get the twitter followers and following person details. i know that not present any direct mechanism to get all the detail. so i first get the id's of all friends. i used this API to get the id's.
NSURL * requestAPI =[NSURL URLWithString:#"https://api.twitter.com/1.1/friends/ids.json"];
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:twitterAccount.username, #"screen_name", nil]; // Fo rthis Api you need to pass these parmeter is necessary
and pass this parameter and get the list of id's.
and using that ids i want to get the all details about friends. so i tried this API
NSURL * requestAPIForNames =[NSURL URLWithString:[NSString stringWithFormat:#"https://api.twitter.com/1.1/users/lookup.json?user_id=%#",result]];
NSMutableDictionary *parameters1 = [[NSMutableDictionary alloc] init];
[parameters1 setObject:#"xxxxxxxxxxxxxxxxxxxx" forKey:#"oauth_consumer_key"];
[parameters1 setObject:#"xxxxxxxxxxxxxxxxxxxxxxxx" forKey:#"oauth_consumer_secret"];
i have pass the all id's to this API. and want to get the details of followers. but not sucess.
i get the following issue.
{
errors = (
{
code = 32;
message = "Could not authenticate you";
}
);
}
why this happening can anyone help me to do this.
thanks in advance.
Related
how to get all near location from passing current location lat & log to google location api ?
i have registered google location api and created url to fetch all near location , but the problem is at a time i am only able to pass one "types" e.g types = atm
i want to pass multiple types like "atm|bar|cafe|florist|park" so that i can able to get all the information by passing single request.
below is url which i am passing
URL : https://maps.googleapis.com/maps/api/place/search/json?location=23.025651,72.507753&radius=4754796&types=bar|cafe&sensor=false&key=AIzaSyDtsmfnmSKSgDGK4s5
But by passing spurted by "|" it will give no records , by passing single type only it will provide full details.
Please help me.
Thanks
I found the solution to request the multiple types for Place API V3 , below is the code by which we can request multiple types and get all near location information.
currentCentre.latitude = 23.025651;
currentCentre.longitude = 72.507753;
NSString *url = [NSString stringWithFormat:#"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%#&types=atm|food&sensor=true&key=%#", currentCentre.latitude, currentCentre.longitude, [NSString stringWithFormat:#"%i", 1000], kGOOGLE_API_KEY];
NSURL *googleRequestURL = [NSURL URLWithString:[url
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
// Retrieve the results of the URL.
dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL: googleRequestURL];
[self performSelectorOnMainThread:#selector(fetchedData:) withObject:data waitUntilDone:YES];
});
From the FetchedData we will get the JSON Response from google and we can able to get all details of requested different types in single request.
Thanks.
I am a newbie iOS learner. Couldn't find answer to following question after searching for a while. Hence, here it is.
Building on a first app that displays recent pictures from a user's instagram feed, I am trying to display pictures from the follows of that users instead.
To call recent pictures from the Instagram feed, which worked well, I had created the following method "imageForPhoto"
+ (void)imageForPhoto:(NSDictionary *)photo size:(NSString *)size completion:(void(^)(UIImage *image))completion {
if (photo == nil || size == nil || completion == nil) {
return;
}
NSString *key = [[NSString alloc] initWithFormat:#"%#-%#", photo[#"id"], size];
NSURL *url = [[NSURL alloc] initWithString:photo[#"images"][size][#"url"]];
[self downloadURL:url key:key completion:completion];
}
Therefore, I first modified my code to get the data related to the "follows" in my PhotosViewController instead of recent media pictures ( v1/users/3/follows ):
NSURLSession *session = [NSURLSession sharedSession];
NSString *urlString = [[NSString alloc] initWithFormat:#"https://api.instagram.com/v1/users/3/follows?count=99&access_token=%#", self.accessToken];
Then, I created a new method that I called friendAvatarForPhoto to get the follows profile pictures from a photo NSDictionary that is passed in as the only method parameter. I placed this method in my PhotoController class:
+ (void)friendAvatarForPhoto:(NSDictionary *)photo completion:(void(^)(UIImage *image))completion {
if (photo == nil || completion == nil) {
return;
}
NSString *key = [[NSString alloc] initWithFormat:#"avatar-%#", photo[#"user"][#"id"]];
NSURL *url = [[NSURL alloc] initWithString:photo[#"profile_picture"]];
[self downloadURL:url key:key completion:completion];
}
It seems to work. I have manually checked that the pictures that are rendered on my UICollectionView are actually coming from the "profile_picture" key of the responseDictionary I get back from Instagram.
Here is the structure of this dictionary: https://www.dropbox.com/s/ldjqupadqg0j3nq/friends_response_dictionary.png
Specifically, as you can see, I modified both the key and the url:
NSString *key = [[NSString alloc] initWithFormat:#"avatar-%#", photo[#"user"][#"id"]];
NSURL *url = [[NSURL alloc] initWithString:photo[#"profile_picture"]];
but I am not really understanding what I need to initial the *key string with... I kept "avatar" for example but why should I? I am pretty sure it's wrong although the result seems to be fine from what is returned on my UICollectionView.
What should I initiate this string with instead?
What is the function of this key in the overall NSURLSession process?
I'd love to better understand the overall process and better connect the dots with Instagram's API so I can query the right key and be sure I am getting what I am looking for. In a reliable way, not an intuitive one as I have just done app-arently.
Any help from experienced developers in the community would be welcome, I've just started to explore iOS dev a few weeks ago based on rusty C skills from a long time back.
Thank you!
:) Arsene
In my app i want to display the videos uploaded by a particular user in his Vimeo account.
I have completed the OAuth steps and got the video_id's of the video's uploaded by user. I tried to download the thumbnails for videos so that they can be displayed in table view or collection view.
Vimeo has provided the api method using that i got the response like this:
NSURL *url = [[NSURL alloc] initWithString:#"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls&video_id=72961770"];
but i pasted the user id there. i tried another approach so that the user id is loaded dynamically.
NSURL *url = [[NSURL alloc] initWithString:#"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc]initWithURL:url consumer:consumer token:token realm:nil signatureProvider:nil];
OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:#"video_id" value:[array objectAtIndex:0]];
NSArray *params = [NSArray arrayWithObject:p0];
[request setParameters:params];
but i got an error saying that Msg = Method not found.
can you help me to get the id dynamically or is there a way to give the video_id as a parameter to the url. Thank you
create a string for url and paste until video_id=.
NSString *url = #"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls&video_id=";
and after that use stringByAppendingString method to append the video_id value to it and use it.
This is also not a direct way but somehow enables you to get the video thumbnails dynamically without having to paste it
I'm trying to get the list of videos returned from querying the URL of video responses in my app, but I can't seem to find any documentation on the topic especially for Objective C. I can get the url of the response list (see code below), but what kind of GData class do I use to have the url return a list of entries or videos in an array or list?
//get video object and get the link from it
GDataEntryYouTubeVideo *video = [videoList objectAtIndex:i];
GDataLink *vidResponses = video.videoResponsesLink;
//resulting link returns an xml feed
vidResponses= https://gdata.youtube.com/feeds/api/videos/luCT5A02n5w/responses
In the completion handler, the feed variable will be a GDataFeedYouTubeVideo, which has a property called entries, which is an array of GDataEntryYouTubeVideos
GDataQueryYouTube * query = [[GDataQueryYouTube alloc] init];
query.feedURL = [NSURL URLWithString:#"https://gdata.youtube.com/feeds/api/videos/luCT5A02n5w/responses"];
GDataServiceGoogleYouTube * service = [[GDataServiceGoogleYouTube alloc] init];
service.userAgent = #"App Name";
[service fetchFeedWithQuery:query
completionHandler:^(GDataServiceTicket *ticket, GDataFeedBase *feed, NSError *error)
{
if(!error)
{
NSArray * entries = feed.entries;
if(entries.count)
{
GDataEntryYouTubeVideo * firstVideo = entries[0];
}
}
}];
It appears that URL has no video responses.
I am trying to retrieve the link to the profile picture...
So far the graph API call :
[facebook requestWithGraphPath:#"me/picture" andDelegate:self];
returns the image itself as Data. When I make the call :
[facebook requestWithGraphPath:#"me/picture" andDelegate:self];
I do get an array of picture with the link for each of them.
Is there anyway to get some sort of similar thing for the profile pic, at least just the link... Or is it not possible?
If someone has already been through this please let me know.
Cheers,
Sami.
make the graph request:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"picture",#"fields",nil];
[facebook requestWithGraphPath:#"me" andParams:params andDelegate:self];
then on request didLoad:
NSString *pictureUrl = [result objectForKey:#"picture"];
If you want additional fields, just add them to the params dictionary:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"id,name,picture",#"fields",nil];
After logged in you can get the profile picture with this link;
https://graph.facebook.com/userId/picture?width=640&height=640
Do you meen anything like the following?
NSString *fbuid = #"1234567890";
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"https://graph.facebook.com/%#/picture", fbuid]];
Or do you need the final url to which the link above redirects you? For the final url I guess you will need a proxy, something of this kind maybe.
UPDATE:
You can also get the link with FQL:
https://developers.facebook.com/blog/post/2012/04/11/platform-updates--operation-developer-love/