I was hoping someone could help me with this problem. I am trying to access a Picasa Web Album from my iphone application. I have used GData previously with Google Calendar and getting events and the data related to them before, so I set up my methods in a similar fashion. I however am getting an error that is telling me the following
serviceBase:<GDataServiceGooglePhotos: 0x4d4e6d0> objectFetcher:<GDataHTTPFetcher: 0xbaa35c0> failedWithStatus:400 data:Too many results requested
I am think that I have narrowed down the problem that I am having has something to do with the ticket that I am using, in the following line
ticket = [service fetchFeedWithURL:[NSURL URLWithString:kGDataGooglePhotosAllFeed]
delegate:self
didFinishSelector:#selector(photosListTicket:finishedWithFeed:error:)];
I however am unable to get past this problem. Does anyone have a suggestion to get past this problem. Am I doing something wrong?
My full code for the retrieval of the pictures is shown below. Anywhere that says picAlbum, that is a predefined NSArray to hold the information.
- (GDataServiceGooglePhotos *)photoService {
static GDataServiceGooglePhotos* service = nil;
if (!service) {
service = [[GDataServiceGooglePhotos alloc] init];
[service setShouldCacheDatedData:YES];
[service setServiceShouldFollowNextLinks:YES];
}
[service setUserCredentialsWithUsername:#"username"
password:#"password"];
return service;
}
-(void)loadGooglePhotos {
[self fetchAllPhotos];
}
-(void)fetchAllPhotos {
NSLog(#"In fetchAllPhotos");
GDataServiceGooglePhotos *service = [self photoService];
GDataServiceTicket *ticket;
ticket = [service fetchFeedWithURL:[NSURL URLWithString:kGDataGooglePhotosKindAlbum]
delegate:self
didFinishSelector:#selector(photosListTicket:finishedWithFeed:error:)];
}
- (void)photosListTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedPhotoAlbum *)feed error:(NSError *)error {
NSLog(#"In photosListTicket");
NSArray *photos = [feed entries];
if ([photos count] != 0){
self.picAlbum = [photos objectAtIndex:0];
NSLog(#"fetching photos");
[self fetchPhotos];
}
else {
NSLog(#"User has no photos...");
}
}
- (void)fetchPhotos {
NSLog(#"In fetchPhotos");
if (self.picAlbum) {
NSURL *feedURL = [[self.picAlbum alternateLink] URL];
if (feedURL) {
NSLog(feedURL);
GDataQueryGooglePhotos *query = [GDataQueryGooglePhotos photoQueryWithFeedURL:feedURL];
[query setMaxResults:1000];
GDataServiceGooglePhotos *service = [self photoService];
GDataServiceTicket *ticket;
ticket = [service fetchFeedWithQuery:query delegate:self didFinishSelector:#selector(photosEventsTicket:finishedWithFeed:error:)];
}
}
}
- (void)photosEventsTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedPhotoAlbum *)feed error:(NSError *)error {
NSLog(#"In photosEventsTicket");
NSArray *photos = [feed entries];
NSLog([NSString stringWithFormat:#"%i",[photos count]]);
}
Thanks in advance for any information or help that you can provide.
If the server says "Too many results requested" that's a clue that the max results query parameter is too big.
The fetches in the code snippet do not appear functional. Neither kGDataGooglePhotosKindAlbum nor an album's alternateLink would be URLs for feeds.
Related
I tried to post from twitter but it not posting the comments. It display an error 204 , in the facebook the same data is successfully posted but in the twitter i got an error can any one have an idea How to solve it
-(void)postDataOnTwitterMethod{
if ([[FHSTwitterEngine sharedEngine]isAuthorized]) {
NSData *dataFromPath = UIImageJPEGRepresentation(cameraImage,1.0);
number = (arc4random()%10000)+1; //Generates Number from 1 to 10000.
RndNo = [NSString stringWithFormat:#"%i", number];
NSLog(#" ITEM %#",RndNo);
NSString *avalabelDate = [NSString stringWithFormat:#"%#_%#",[CommonMethods getCurrentDateAndTime],self.AvailableTillTextField.text];
NSString *theWholeString = [NSString stringWithFormat:#"Item No: %#\nItemName: %#\nItemCost: %#\nAvailableTill: %#\nCategory: %#\nDescription: %#",RndNo,self.NameTextField.text,self.PriceTextField.text,avalabelDate,self.ListTypeTextField.text,self.DecTextView.text];
dispatch_async(GCDBackgroundThread, ^{
#autoreleasepool {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSError *returnCode = [[FHSTwitterEngine sharedEngine]postTweet:theWholeString withImageData:dataFromPath];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSString *title = nil;
NSString *message = nil;
if (returnCode) {
title = [NSString stringWithFormat:#"Error %d",returnCode.code];
message = returnCode.localizedDescription;
} else {
title = #"Tweet Posted";
}
dispatch_sync(GCDMainThread, ^{
#autoreleasepool {
UIAlertView *av = [[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[av show];
}
});
}
});
}
else{
[[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:self withCompletion:^(BOOL success) {
NSLog(success?#"L0L success":#"O noes!!! Loggen faylur!!!");
}];
}
}
Your comments made me smile.
I believe it's an HTML error. It means the data was received and understood but you shouldn't expect a return. In other words, it's void. At least that's what I can see with a quick look around your code and my minimal understanding of Twitter API.
Now i am able to send the String but cant able to send the Image using this method
NSError *returnCode = [[FHSTwitterEngine sharedEngine]postTweet:theWholeString withImageData:imageData];
FHSTwitterEngine has some known bugs, and the problem is now fixed, see below:
Getting error while posting image using FHSTwitterEngine
compress the existing image with this code and you will get images posted.
NSData *data = UIImageJPEGRepresentation(imageView.image, 0.6);
Im developing an app for iPhone, in wich one of the functionalities is an instant message system, using XMPPFramework. By now, im testing it with Google Talk. The delegate is the same class that manages the User Interface. So, I got this code:
In viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
[self setupStream];
}
The setupStream method:
- (void) setupStream
{
NSLog(#"Inside setupStream");
xmppStream = [[XMPPStream alloc] init];
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self connect];
}
The connect method:
- (BOOL) connect
{
NSLog(#"Inside connect method");
General *general = [General sharedManager];//this is a singleton to manage settings for every user
NSString *chatid;
NSString *chatpass;
//chatid=[general user];
chatid=#"somegmailaccount#gmail.com";
xmppStream.myJID=[XMPPJID jidWithString:chatid];
if (![xmppStream isDisconnected]) {
return YES;
}
NSError *error = nil;
if (![xmppStream connect:&error])
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:[NSString stringWithFormat:#"Can't connect to server %#", [error localizedDescription]]
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alertView show];
return NO;
}
return YES;
}
In xmppStreamDidConnect method:
- (void) xmppStreamDidConnect:(XMPPStream *)sender
{
[xmppStream authenticateWithPassword:#"password" error:NULL];
[self goOnline];
}
And goOnline method:
- (void) goOnline
{
XMPPPresence *presence = [XMPPPresence presence];
[[self xmppStream] sendElement:presence];
NSLog(#"Presence sent");
}
With this, the presence is not sent. I have another google account that I try for testing (say, testing#gmail.com) and in this account the presence of somegmailaccount.gmail.com is not seen. Both accounts are connected and know each other, since I used this same accounts to develop the Android app.
Any idea about what i´m doing wrong? Any help is appreciated.
Thank you very much.
I found it! The presence is not sent this way:
XMPPPresence *presence = [XMPPPresence presence];
[[self xmppStream] sendElement:presence];
Insted, i have done it this way:
NSXMLElement *presence = [NSXMLElement elementWithName:#"presence"];
[xmppStream sendElement:presence];
This way, the presence is sent without any problem :)
With this code, i implement method xmppStreamDidAuthenticate:(XMPPStream *)sender
and the program DO enter that method without any call from my code. But if i put
[xmppStream setHostName:#"talk.google.com"];
[xmppStream setHostPort:5222];
... in method connect, the program DO NOT enter that method, nor xmppStreamDidConnect.
Im getting mad.
I'm trying to implement fetching an picasa web album on iphone, have downloaded the code and example from google.code but have run into a problem where fetching an album feed returns me feed with wrong object types - GDataEntryBase instead of GDataEntryPhoto.
Here's the code I'm using:
First I'm calling this to get all my albums:
- (void)fetchAllAlbums
{
NSLog(#"Fetching all albums");
//request albums
GDataServiceTicket *ticket;
NSURL *feedURL = [GDataServiceGooglePhotos photoFeedURLForUserID:myemail
albumID:nil
albumName:nil
photoID:nil
kind:nil
access:nil];
ticket = [_GooglePhotoService fetchFeedWithURL:feedURL
delegate:self
didFinishSelector:#selector(albumListFetchTicket:finishedWithFeed:error:)];
[self set_AlbumFetchTicket: ticket];
}
Now, in the callback I call to get all the photos of each returned album:
- (void)albumListFetchTicket:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedPhotoUser *)feed
error:(NSError *)error
{
[self set_UserAlbumFeed: feed];
[self set_AlbumFetchError:error];
[self set_AlbumFetchTicket:nil];
if (error == nil) {
NSLog(#"Got albums!");
for (GDataEntryPhotoAlbum * albumEntry in _UserAlbumFeed)
{
NSLog(#"Album Title: %#", [[albumEntry title] stringValue]);
{
NSLog(#"Fetching photos!");
[self set_AlbumPhotosFeed:nil];
[self set_PhotosFetchError:nil];
[self set_PhotosFetchTicket:nil];
GDataServiceTicket *ticket;
ticket = [_GooglePhotoService fetchFeedWithURL: [[albumEntry feedLink] URL]
delegate: self
didFinishSelector: #selector(photosTicket:finishedWithFeed:error:)];
[self set_PhotosFetchTicket:ticket];
}
}
}
}
and this is the callback for each album photo feed fetch:
// photo list fetch callback
- (void)photosTicket:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedPhotoAlbum *)feed
error:(NSError *)error
{
//tell me what class you are
NSLog(#"Feed class: %#", NSStringFromClass([feed class]));
[self set_AlbumPhotosFeed: feed];
[self set_PhotosFetchError: error];
[self set_PhotosFetchTicket: ticket];
if (error == nil)
{
NSLog(#"Got Photos!");
for (GDataEntryPhoto * photo in feed)
{
NSLog(#"Title: %#", [[photo title] stringValue]);
//tell me what class you are
NSLog(#"%#", NSStringFromClass([photo class]));
//NSArray * thumbnails = [[photo mediaGroup] mediaThumbnails];
//NSLog(#"thumbnails count: %d", [thumbnails count]);
//NSLog(#"Photo thumnail url: %#", [[thumbnails objectAtIndex:0] URLString]);
}
}
}
The trouble is that the entries in the feed in the last callback are not of type GDataEntryPhoto, just the base GDataEntryBase - and so trying to access their thumbnail urls will crash the app.
The code is copied from google's cocoa (non-touch) example, and there it works - the feed returned is populated with the GDateEntryPhoto objects.
Any help would be greatly appreciated.
Add -ObjC -all_load to Other Linker Flags in your xcodeproject, then add SystemConfiguration.framework, CFNetwork.framework and Security.framework to Build Phases -> Link Library With Binaries.
I'm trying to integrate GData/YouTubeAPI into my project but I'm a bit stuck. I used the code that was given in this post:
Any examples/tutorials on using Google GData API - Youtube on iphone?
My problem is that the function 'request:finishedWithFeed:error:' is not called when the GData service is done grabbing data off the interwebs.
My program compiles and runs – and no runtime errors present themselves. I also checked and feedURL returns a valid URL. I debugged this and 'service' does manage to return a value.
GDataServiceGoogleYouTube *service = [self youTubeService];
// feed id for user uploads
NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
// construct the feed url
NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:USER_NAME userFeedID:uploadsID];
// make API call
[service fetchFeedWithURL:feedURL delegate:self didFinishSelector:#selector(request:finishedWithFeed:error:)];
This is the header for the function I'm trying to get service to call when its done, it's located in the same object as the other code i've posted
- (void)request:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedBase *)aFeed error:(NSError *)error;
SOLUTION --
make sure its running on main thread --
-(id)initWithVideosArrayURLString:(NSString*)url {
if (self = [super init]) {
NSLog(#"loading");
[self performSelectorOnMainThread:#selector(initMainThreadWithURLString:) withObject:url waitUntilDone:NO];
}
return self;
}
-(void)initMainThreadWithURLString:(NSString*)url {
GDataServiceGoogleYouTube *service = [self youTubeService];
NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:#"annoyingorange" userFeedID:uploadsID];
[service fetchFeedWithURL:feedURL delegate:self didFinishSelector:#selector(serviceTicket:finishedWithFeed:error:)];
NSLog(#"sent");
}
- (void)serviceTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedBase *)aFeed error:(NSError *)error {
self.feed = (GDataFeedYouTubeVideo *)aFeed;
NSLog(#"success.");
}
Is your code on the main thread, and returning to the run loop after initiating the fetch? Callbacks occur only when the app's run loop is spinning.
hello all i want to retrieve my all the wall post that i have posted until now i am using this fql query from my native iphone application in order to fetch it but i think i am maiking some mistake please guide me how could i do that the following is my fql query to get wall post
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
NSString *fql = [NSString stringWithFormat:#"SELECT comments, likes FROM stream WHERE post_id=100000182297319"];
NSLog(#"session key is %#",_session.sessionKey);
NSLog(#"from global key is %#",[twitfacedemoAppDelegate getfacebookkey]);
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"query"];
[[FBRequest requestWithDelegate:self] call:#"facebook.fql.query" params:params];
this is my other delgate method to get the wall post but this code is not working
- (void)request:(FBRequest*)request didLoad:(id)result {
#try
{
NSLog(#"result is %#",result);
if(result==nil)
{
UIAlertView *a=[[UIAlertView alloc]initWithTitle:#"Can't login" message:#"You cant login here." delegate:nil cancelButtonTitle:#"ok" otherButtonTitles:nil];
[a show];
[a release];
}
else
{
NSArray* users = result;
NSDictionary* user = [users objectAtIndex:0];
NSString* name = [[NSString alloc]initWithString:[user objectForKey:#"name"]];
NSLog(#"name is %#",name);
_label.text = [NSString stringWithFormat:#"Logged in as %#", name];
NSString *globalfacebookname;
globalfacebookname=[[NSString alloc]initWithString:name];
NSLog(#"value is %#",globalfacebookname);
NSString *fid=[user objectForKey:#"uid"];
NSLog(#"FACEBOOK ID WITH STRING DATATYP %#",fid);
[twitfacedemoAppDelegate fetchfacebookid:fid];
}
}
#catch (NSException * e)
{
NSLog(#"Problem in dialog didFailWithError:%#",e);
}
}
please guide me how could i retrieve my all the post from facebook to my native iphone application through fql query
thanks in advance
Maybe I'm retarded but I tried this and I always get an empty NSArray back. I am substituting my source_id with my uid obviously with %lld and before I request this I am successfully getting my full name from my profile (so I must be authenticated). This is the exact query I'm using: SELECT actor_id, message FROM stream WHERE source_id = 610611343 limit 50
Do I have to request permissions first or something? Help would be greatly appreciated because I've been going for hours on this and want to pull my hair out. I wish an error code at least would come back - but its always just nothing.
cheers i got it i have fired one query after establishing the connection and i got my wall post back to native iphone application here is my query
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
//_permissionButton.hidden = NO;
//_feedButton.hidden = NO;
NSLog(#"DISABLED");
NSString *fql = [NSString stringWithFormat:#"SELECT actor_id, message FROM stream WHERE source_id = 100000182297319 limit 50"];
NSLog(#"session key is %#",_session.sessionKey);
NSLog(#"from global key is %#",[twitfacedemoAppDelegate getfacebookkey]);
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"query"];
[[FBRequest requestWithDelegate:self] call:#"facebook.fql.query" params:params];
}
and here is the result of it
- (void)request:(FBRequest*)request didLoad:(id)result {
#try
{
NSLog(#"result is %#",result);
//startride.enabled=FALSE;
//selectride.enabled=FALSE;
if(result==nil)
{
UIAlertView *a=[[UIAlertView alloc]initWithTitle:#"Can't login" message:#"You cant login here." delegate:nil cancelButtonTitle:#"ok" otherButtonTitles:nil];
[a show];
[a release];
}
else
{
NSArray* users = result;
NSDictionary* user = [users objectAtIndex:0];
}
}
#catch (NSException * e)
{
NSLog(#"Problem in dialog didFailWithError:%#",e);
}
}
at this point you will get all the wall post in to the results dictionary