Upload image to Picasa with Objective C on iPhone - iphone

I was wondering if anyone had any information of code that they have used to upload an image to Picasa. I really only need the code to upload images, I have everything working to get the image feed and view it, but going the other way is giving me a problem.
Google does not really provide any good documentation for how to do this. Any help would be greatly appreciated, thanks in advance!

Check this code:
GDataServiceGooglePicasaWeb* service =
[[GDataServiceGooglePicasaWeb alloc] init];
[service setUserCredentialsWithUsername:#"my.account#gmail.com"
password:#"mypasswd"];
// get the URL for the album
NSURL *albumURL = [GDataServiceGooglePicasaWeb
picasaWebFeedURLForUserID:#"my.account" albumID:nil
albumName:#"MyBestPhotos" photoID:nil kind:nil access:nil];
// set a title and description for the new photo
GDataTextConstruct *title, *desc;
title = [GDataTextConstruct textConstructWithString:#"Sunset Photo"];
desc = [GDataTextConstruct textConstructWithString:#"A nice day"];
GDataEntryPhoto *newPhoto = [GDataEntryPhoto photoEntry];
[newPhoto setTitle:title];
[newPhoto setPhotoDescription:desc];
// attach the photo data
NSData *data = [NSData dataWithContentsOfFile:#"/SunsetPhoto.jpg"];
[newPhoto setPhotoData:data];
[newPhoto setPhotoMIMEType:#"image/jpeg"];
// now upload it
GDataServiceTicket *ticket;
ticket = [service fetchPicasaWebEntryByInsertingEntry:newPhoto
forFeedURL:albumURL
delegate:self
didFinishSelector:#selector(addPhotoTicket:finishedWithEntry:)
didFailSelector:#selector(addPhotoTicket:failedWithError:)];
Source: http://googlemac.blogspot.com/2007/06/picasa-web-albums-meets-google-data.html

Related

How to post an images on Google Plus in an iOS Application

I successfully posted content and (Links)URL using Google Plus API in iphone.
Using Following code:
googleShare =[[[GooglePlusShare alloc] initWithClientID:#"my key"] autorelease];
[googleShare setDelegate:self];
appDelegate.shareGOOGLe =googleShare;
NSString *inputURL = #"";
NSURL *urlToShare = [inputURL length] ? [NSURL URLWithString:inputURL] : nil;
NSLog(#"%#",urlToShare);
NSString *inputText = #"TEst Sharing testing from iOS 5.0";
NSString *text = [inputText length] ? inputText : nil;
NSLog(#"%#",text);
[[[[googleShare shareDialog]
setURLToShare:urlToShare]
setPrefillText:shareMessge] open];
But I want to post images to google plus.
Can any one help me?
Thanks in advance.
It is currently not possible to share images on Google+ with the Google+ iOS SDK.
This is possible to share a Image with google plus
- (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[shareBuilder attachImage:[UIImage imageNamed:#"yourImagename.png"]];
[shareBuilder open];
}
Referenced from https://developers.google.com/+/mobile/ios/share/
#Chirag... You should see Flipboard application for iPhone/iPad. It shares the link,comment and Image on Google+ account. Please take a look and let me know if i am wrong at any point.
These are the links will help:
Link Shows how and what can be shared.
https://developers.google.com/+/mobile/ios/share/
at the bottome of link 1, it mentions "Attaching media to your shared posts. You can attach pictures and movies to your posts for your users to share to their stream."
https://developers.google.com/+/mobile/ios/share/media
Link 2 shows the code snippet to share the media ; images and videos
Following is the Code snippet to share Image on google+
- (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
// Set any prefilled text that you might want to suggest
[shareBuilder setPrefillText:#"Achievement unlocked! I just scored 99 points. Can you beat me?"]
NSString *fileName = #"samplemedia1";
[shareBuilder attachImage:[UIImage imageNamed:fileName];
[shareBuilder open];
}

Reading image metadata from web URL

Been looking around and can't find a definite way to do this...
I need to read the meta data from an image found at a certain URL. Is there a way to do this on the iphone?
Re-answer:
Try this: http://code.google.com/p/iphone-exif/
You should be able to fetch the image properties (metadata). Hope this helps :)
I tried using iphone-exif and it just wasn't working in my project. Saw a lot of people getting the same errors as me.
Good news is I found another solution...
NSDictionary *IPTCDict;
NSString *urlString = #"http://SOMEIMAGEURL.jpg";
NSMutableData *photoData = [NSMutableData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)photoData, NULL);
NSDictionary *metadata = (__bridge NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSLog(#"Meta: %#", metadata); //Will print out all the metadata
// Pulls out the IPTC data
IPTCDict = [metadata objectForKey:(NSString *)kCGImagePropertyIPTCDictionary];
NSLog(#"Caption: %#\nCopyright: %#", [IPTCDict objectForKey:#"Caption/Abstract"], [IPTCDict objectForKey:#"CopyrightNotice"]);

How to get a link of the video I uploaded to YouTube

My code can upload the video to YouTube successfully, I want to get the embed link of the uploaded video, and put this link to another website, so that I can see the video from that website.
How can I get that link?
I use code below to upload the video, but I can not see any useful information from the returned ticket.
GDataServiceTicket *ticket;
ticket = [service fetchEntryByInsertingEntry:entry
forFeedURL:url
delegate:self
didFinishSelector:#selector(uploadTicket:finishedWithEntry:error];
Is there anyone can help me out here?
Thanks a lot
You should be able to get the url from the entry object in your callback handler.
- (void)uploadTicket:(GDataServiceTicket *)ticket
finishedWithEntry:(GDataEntryYouTubeVideo *)videoEntry
error:(NSError *)error {
if (error == nil) {
NSString *url = [[[[video mediaGroup] mediaContents] objectAtIndex:0] URLString];
}
}

adding photo on facebook wall

- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = [NSString stringWithFormat: subjectTitle]; //subjectTitle works here but not as name where i need it.
NSString *src = #"http://www.sample.com/image.png";
NSString *name = storyLink; //<---------------------------------works with storyLink but not subjectTitle. I need subjectTitle to work here
NSString *href = storyLink;
NSString *attachment = [NSString stringWithFormat:#"{\"name\":\"%#\",\"media\":[{\"type\":\"image\", \"src\":\"%#\", \"href\":\"%#\"}]}", name, src, href];
dialog.attachment = attachment;
[dialog show];
}
i want to add image from photo library instred of http://www.sample.com/image.png to the facebook wall.
can anyone provides me help ....
Thanks in advance ......
You can access the URL's of the iPhoto library items using the UIImagePickerController and its delegate method.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
When the user picks a photo the URL will be in the dictionary under the key UIImagePickerControllerMediaURL
Probably this Stack Overflow Question about uploading images to Facebook might help you.
Also Sharekit is a nice framework to add Social features to you iPhone App. I think it has facility to share images. You can check it out at Sharekit official website.

How to post images with text in facebook integration in Iphone sdk

Here Iam having a problem.Actually I implemented the facebook integration in my application and I need to post the images with text but I dont have any idea how to work on this.can anyone suggest this with a sample code so that it is very helpful for me.
Anyone's help will be much appreciated.
I assume that you want to draw some text in an image, and then upload the image to Facebook.
At first, we need to draw the original image and the desired text into a new image.
UIGraphicsBeginImageContext(CGSizeMake(320.0, 320.0));
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw the original image
[image drawInRect:CGRectMake(0, 0, 320.0, 320.0)];
// Draw the text
[#"text" drawInRect:CGRectMake(...) withFont:[UIFont systemFontOfSize:20.0];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
And then, convert the image into NSData and call Facebook's "photos.upload" API to upload it.
NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:#"caption" forKey:#"caption"];
FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
NSData *data = UIImagePNGRepresentation(newImage);
[uploadPhotoRequest call:#"photos.upload" params:args dataParam:data];
If you want to upload the images to your server, and post a small story to Facebook's wall. Use the stream API.
FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.userMessagePrompt = #"Prompt";
NSString *name = #"Your caption";
NSString *src = #"http://example.com/path/of/your/image";
NSString *href = #"http://what/happens/if/the/user/click/on/the/image";
NSString *attachment = [NSString stringWithFormat:#"{\"name\":\"%#\",\"media\":[{\"type\":\"image\", \"src\":\"%#\", \"href\":\"%#\"}]}", name, src, href];
dialog.attachment = attachment;
[dialog show];
Maybe you would be happy using BMSocialShare. It's a simple lib I wrote.
BMFacebookPost *post = [[BMFacebookPost alloc]
initWithTitle:#"Simple sharing via Facebook, Email and Twitter for iOS!"
descriptionText:#"Posting to Facebook, Twitter and Email made dead simple on iOS. Simply include BMSocialShare as a framework and you are ready to go."
andHref:#"https://github.com/blockhaus/BMSocialShare"];
[post setImageUrl:#"http://www.blockhausmedien.at/images/logo-new.gif"
withHref:#"http://www.blockhaus-media.com"];
[[BMSocialShare sharedInstance] facebookPublish:post];