How to implement sharing via Twitter, mail & Tumblr using ShareKit - iphone

I am trying to use ShareKit to implement sharing via Twitter, mail & Tumbler but I am unable to make them work correctly.
I implemented the following code on view load,
SHKItem *item;
item=[SHKItem image:[UIImage imageNamed:#"icon2.png"] title:#"Praveen"];
[SHKFacebook shareItem:item];
Please help me..

Try these following lines ;) it works for me :)
NSString *imageName=[NSString stringWithFormat:#"marriage0.jpg"];
NSString *message=[NSString stringWithFormat:#"%#",self.myMessage.text];
UIImage *image =[UIImage imageNamed:imageName];
SHKItem *fbItem = [SHKItem image:image title:message];
[SHKFacebook shareItem:fbItem];

Related

Loading server image using initWithData not working

I am using following code to display image from server in UIImageView.
NSURL *url = [NSURL URLWithString:#"http://www.gettyicons.com/free-icons/125/miscellaneous/png/256/apple_256.png"];
NSData *imageData =[[NSData alloc] initWithContentsOfURL:url];
imgLargePicture.image = [[UIImage alloc] initWithData:imageData];
I can see the picture in Saffari but the image is not rendered in the iPhone application. I searched a lot on net and even in stackoverflow, everywhere this same code is given to display image from server. But in my case somehow its not working.
Can anyone please help me with this?
I use the same code of you and i get the image, so please check the NSData and make sure that imageView IBOutlet should be properly connected. Same code is running fine at my side i have check in xcode.
Just tried that code in my app and it worked. You are not adding that "imgLargePicture" (I assume it's a UIImageView) as your UIViewController's view subview or not giving it a proper frame.
Try this in your -viewDidLoad: and see if it works
UIImageView *imgLargePicture = [[UIImageView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:imgLargePicture];
NSURL *url = [NSURL URLWithString:#"http://www.gettyicons.com/free-icons/125/miscellaneous/png/256/apple_256.png"];
NSData *imageData =[[NSData alloc] initWithContentsOfURL:url];
imgLargePicture.image = [[UIImage alloc] initWithData:imageData];
This was happening because of proxy server setup in the organization. It required me to provide user name & password to go through proxy. So this is fixed by implementing AuthenticationChallenge method where I passed the credentials.

How can I add a specific email recipient to my sharekit item?

So, I'm using sharekit to share some text. I need to be able to send the email to a pre-defined recipient. How can I set the mail recipient to the sharekit item?
Sharekit has now implemented this. You can use the example below.
NSURL *url = [NSURL URLWithString:#"Your URL"];
SHKItem *item = [SHKItem URL:url title:#"Your title" contentType:SHKURLContentTypeUndefined];
NSArray *recipientArray = [NSArray arrayWithObjects:#"mail#example.com",nil];
[item setMailToRecipients:recipientArray];
[SHKMail shareItem:item];
I found the answer here:
ShareKit
UPDATE: Sharekit has an update that takes care of this now. See the newly accepted answer.

ShareKit for Facebook in iPhone application

I can't get ShareKit to work. I dragged ShareKit into my app with checked copy option. I also updated the shkconfig file with my Facebook key, secure key, and used the following code:
SHKItem *item = [SHKItem text:#"Praveen Kumar Tripathi"];
SHKFacebook *faceBook=[SHKFacebook shareItem:item];
[faceBook share];
in viewDidLoad.
But I'm not able to see Facebook screen. I'm seeing a blank screen.
You weren't completely clear, so I'm not sure what your asking, but it sounds like you want to show a facebook login at launch. The way you do that is like this:
First, #import "SHKFacebook.h"
then in your button, put then in the viewDidLoad:
SHKItem *item;
this creates the sharekit item
then:
NSURL *url = [NSURL URLWithString:#"http://itunes.apple.com/us/app/...?mt=8"];
put the link to your app here. This link is so if someone clicks on the Facebook post, they will be directed to the iTunes store to download your app.
Then set the basic text for your post. This text is set by you. The user Cannot change this text. (Obviously this is what I do, you can make this text anything you want)
item = [SHKItem URL:url title:[NSString stringWithFormat:#"I'm playing someGame on my iPhone! My Highscore is %i, think you can beat it?", highScoreInt]];
Then set up the post like this:
item = [SHKItem URL:url title:#"Share Me!"];
finally show the item:
[SHKFacebook shareItem:item];
I hope this helps.

Posting message along with an image on Facebook [duplicate]

This question already has an answer here:
Closed 11 years ago.
How do I post a message on Facebook while uploading an image on Facebook?
In my project I'm using FBFeedPost for uploading images on Facebook and is working fine, but I have to post a message along with the image.
I recommend ShareKit, easily setup and supporting the facebook features you requested.
After installing authorization is done with just:
SHKSharer *service = [[[SHKFacebook alloc] init] autorelease];
[service authorize];
After that it's
SHKItem *item = [SHKItem image:myImage title:#"Look at me!"];
[SHKFacebook shareItem:item];
for an image and for text:
SHKItem *item = [SHKItem text:text];
[SHKFacebook shareItem:item];

posting UIImage to facebook along with other text

i'm trying to post an image on facebook using the following code.
FBStreamDialog* dialog ;
if([FBSession session].isConnected)
dialog = [[[FBStreamDialog alloc] initWithSession:[FBSession session]] autorelease];
else
dialog = [[[FBStreamDialog alloc] initWithSession:session] autorelease];
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"%#\",\"media\":[{\"type\":\"image\",\"src\":\"%#\"}]}", strEventStatus,eventImg];
[dialog show];
Does the media tag have any other property apart from src which would take and image in form of NSData? how do i post the image otherwise?
While you are linking the attachment property for a Image the source should be a URL.. I dont think You can post a UIImage by using attachment.. One solution is you can have a webservice for posting the image in your server and then give that URL when you are posting.
I dont know which Facebook API you are using..
This what i did to upload a image by using Facebook Graph API
UIImage *img = [UIImage imageNamed:#"myImage.png"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
nil];
//facebook is a facebook Obj which I initialized before
[facebook requestWithMethodName:#"photos.upload"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
I have no knowledge of the Facebook API you are using, but it would seem Image SRC would imply that the image is already somewhere on the web.
Have you considered uploading the image to a server somewhere and using the SRC of the image as a URL?
I hope this helps!
You can directly take a UIimage and upload via the code used by BuildSucceeded, you no longer need to forward the image to a server and link via URL. You can also call the image from a UIimageview, camera or library.