Error in integrating ShareKit App iOS - iphone

I want to use shareKit app in my project but when i m trying to post image on facebook i am getting this error .
Error: This endpoint has been deprecated. To temporarily enable it, you may disable the "august 2012" platform migration. It will be disabled permanently on August 1, 2012.
i am using latest SDK or ShareKit.

You dont need to use ShareKit to implement Facebook Integration. Use the new iOS 6 SLComposeViewController to post to Facebook
Here is the full code to post to Facebook
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) //check if Facebook Account is linked
{
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:[NSString stringWithFormat:#"Test",mySLComposerSheet.serviceType]];
[mySLComposerSheet addImage:yourimage]; //an image you could post
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output;
switch (result) {
case SLComposeViewControllerResultCancelled:
output = #"Action Cancelled";
break;
case SLComposeViewControllerResultDone:
output = #"Post Successfull";
break;
default:
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Facebook" message:output delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}];

You're not using the latest version. The latest version is: ShareKit 2.0.
If you use Facebook, Twitter or SinaWeibo with iOS6 only it is really more straightforward to use social.network directly.

Related

How to login to Twitter account from an iOS APP in iOS 7?

I need to login to my twitter from my iOS app. I am able to check if there are any accounts that are set up in the settings in the device. Once it is confirmed that there are no accounts configured in the device, i want to able to login to my twitter account and then add the account to my device. I had a little luck in implementing checking if there are any accounts set up in the device using ACAccountStore. But can someone please help in implementing the later part in iOS7?
SLComposeViewController *sheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
SLComposeViewControllerCompletionHandler completionBlock = ^(SLComposeViewControllerResult result){
[sheet dismissViewControllerAnimated:YES completion:Nil];
};
sheet.completionHandler = completionBlock;
sheet.view.hidden = YES;
[_mainViewController presentViewController:sheet animated:YES completion:nil];
- (IBAction)tweetTapped:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Your Tweet Message! :)"];
if (self.imageString)
{
[tweetSheet addImage:[UIImage imageNamed:self.imageString]];
}
if (self.urlString)
{
[tweetSheet addURL:[NSURL URLWithString:self.urlString]];
}
[self presentViewController:tweetSheet animated:YES completion:nil];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:#"Sorry"
message:#"You can't tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}
}

Twitter login with compatibility of ios5.0,5.1,6.0

As twitter framework is added in ios5.0 I am using its class TWTweetComposeViewController
if([TWTweetComposeViewController canSendTweet])
{
NSLog(#"can send tweet");
}
else{
NSString *message = #"The application cannot send a tweet at the moment. This is because it cannot reach Twitter or you don't have a Twitter account associated with this device.";
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Oops" message:message delegate:nil cancelButtonTitle:#"Dismiss" otherButtonTitles:nil];
[alertView show];
}
On this step I need to show user the login page of twitter.For that I am confused if i should redirect user to settings to login to user?
And if yes this code is not working
NSURL *twitterURL = [NSURL URLWithString:#"prefs:root=TWITTER"];
[[UIApplication sharedApplication] openURL:twitterURL];
Also I have read some where that this will not work in ios6. So what should i do to just make user login for a moment and not send tweet directly. Right now i just want to make user login.
I also refer to this question It is working with ios6 well but in that case how do i handle for ios5.1 ?
Any help will be appreciated....
I figured it out with below conditional coding..
I got only this way. If anyone have any other way please suggest me.
if (SYSTEM_VERSION_LESS_THAN(#"6.0")) {
if(SYSTEM_VERSION_EQUAL_TO(#"5.0"))
{
NSURL *twitterURL = [NSURL URLWithString:#"prefs:root=TWITTER"];
[[UIApplication sharedApplication] openURL:twitterURL];
}else{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"No_Tw", nil) message:NSLocalizedString(#"No_TW_Ac", nil) delegate:nil cancelButtonTitle:NSLocalizedString(#"Button_Ok", nil) otherButtonTitles:nil, nil];
[alertView show];
}
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"6.0")) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.view.hidden=TRUE;
[self presentViewController:tweetSheet animated:NO completion:^{
[tweetSheet.view endEditing:YES];
}];
}
If iOS is 5.0 then it will redirect to login of Twitter otherwise it will show alert to user to go to settings and do login. And for for iOS 6.0 and larger SLComposeViewController is working fine.

Face book and twitter integration to iphone app not working on device

I am very new to iOS development.I am making an application in which i required to integrate twitter and Facebook for wall posting.
I have done all the required coding for this and on simulator it is working fine but not on device.
one more question as the coding for Facebook integration i have copied it from other "demo" application.So what else we need to change in it to make it for my own application.Because when i see my update done by my app on Facebook wall, "demo" app name comes there with the post.
Please guide me !!Thanking you in Advance!!
Facebook
It seems you have jumped to coding part before reading the documentation. Before integrating facebook sdk and writing your code, you need create a new app section in facebook developer console, get an Facebook app id. You need to use that app id in your project, not the app id shipped with facebook demo application.
Documentation explains the process fully, no need to rewrite it here. Make sure you read it to the end.
Twitter
I am not sure if you are having problem in twitter also (question is unclear on that). If yes, you should tell how you are connecting to twitter. But generally, from the tone of your questions, it seems you haven't read the documentation, on creating an app section in respective developer console, and getting app id.
I don't know how much integration you need or if your willing to require iOS 6 but in iOS 6 it is SO MUCH easier to integrate Facebook and Twitter.
This is all the code:
In the header file:
#import "Social/Social.h"
In the main file:
//Twitter
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Cancelled");
} else {
NSLog(#"Done!");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:#"Status Text"];
[self presentViewController:controller animated:YES completion:Nil];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Sorry" message:#"You can't send a tweet right now. You must be online and signed into at least one Twitter account." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
//Facebook
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Cancelled");
} else {
NSLog(#"Done!");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:#""];
[self presentViewController:controller animated:YES completion:Nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Facebook Error" message:#"Either you are not logged into Facebook or your Facebook username and password are incorrect." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
}
You Can use Share kit framework, http://getsharekit.com
As per integrating twitter in your application.Try this code
at self.fullimage write any url of image.
Call buildTweetSheet method to post to twitter.
import Twitter.framework
import
#property(nonatomic,strong) TWTweetComposeViewController *_tweetSheet;
#synthesize _tweetSheet;
-(void)buildTweetSheet
{
NSLog(#"buildTweetSheet");
_tweetSheet = [[TWTweetComposeViewController alloc] init];
UIImage *eimage=UIImage *eimage=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.fullimage]]];
[_tweetSheet setInitialText:#""];
[_tweetSheet addImage:eimage];
[_tweetSheet setInitialText:#""];
[self presentModalViewController:_tweetSheet animated:YES];
TWTweetComposeViewControllerCompletionHandler completionHandler = ^(TWTweetComposeViewControllerResult result)
{
if(result == TWTweetComposeViewControllerResultDone) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Done" message:#"Image Posted Successfully" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Failed" message:#"Image Posted Failed" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
[self dismissModalViewControllerAnimated:YES];
};
[_tweetSheet setCompletionHandler:completionHandler];
}

How can i hide the url of image when i post image on the Facebook by fbconnect?

I am using this code for post the image on the facebook but it also shows image url on the facebook. I want to hide this url:
this is my code for posting an image to facebook
#pragma mark Facebook
-(void)facebook
{
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"I'm using Shape App", #"message", #"I'm using Shape App", #"caption",
#"http://www.imageurlhost.com/images/3kft472rvl2qtnzx11_Sample.png", #"picture",
#"I'm using Shape App", #"title",nil];
[[delegate facebook] dialog:#"feed" andParams:params andDelegate:self];
}
please check the image below
What you are doing is posting a URL, so it shows up as that: A link you shared. It does not matter that this link does point to an image and not a website.
Your options to change that are,
a) post a link to an Open Graph page instead, that contains the image – then you can set a title and description that will show up for that shared link, or
b) post it as a real photo, https://developers.facebook.com/docs/reference/api/user/#photos
i have resolved by latest ios6 facebook integration:
for this you have to import Social.framework after this put this code in method where you want to call Facebook.but it will work only in iOS 6 and later
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL urlWithString:#"http://www.imageurlhost.com/images/3kft472rvl2qtnzx11_Sample.png"]];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:[NSString stringWithFormat:#"I am using Shape App"]];
[mySLComposerSheet addImage:[UIImage imageWithData:imageData]];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
else
{
UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:#"No Facebook Account" message:#"There are no Facebook accounts configured.You can add or create a Facebook account in Settings" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alertView show];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result)
{
// NSLog(#"dfsdf");
switch (result) {
case SLComposeViewControllerResultCancelled:
break;
case SLComposeViewControllerResultDone:
break;
default:
break;
}
}];

Facebook Integration With iOS6

I am using the following code to post something on Facebook.
- (IBAction)post:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
mySocialComposer = [[SLComposeViewController alloc]init];
mySocialComposer = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySocialComposer setInitialText:#"Hellooooooo World"];
[mySocialComposer addImage:[UIImage imageNamed:#"image.jpg"]];
[self presentViewController:mySocialComposer animated:YES completion:nil];
[mySocialComposer setCompletionHandler:^(SLComposeViewControllerResult result){
NSString *outout = [[NSString alloc] init];
switch (result) {
case SLComposeViewControllerResultCancelled:
outout = #"Post Cancled";
break;
case SLComposeViewControllerResultDone:
outout = #"Post Successfull";
default:
break;
}
UIAlertView *myalertView = [[UIAlertView alloc]initWithTitle:#"FaceBook"
message:outout delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[myalertView show];
}];
}
}
I am using the above method to post on Facebook from iOS app.If I do post including an Image and some text it successfully post ed on Facebook. But when I try to post on Facebook without the image just text for that purpose i comment out the following line.
[mySocialComposer addImage:[UIImage imageNamed:#"image.jpg"]];
And while doing that i got an error alert that This post cannot be sent because connection to Facebook lost. Is there any way that i can post on Facebook without image . Thanks in advance.
You can just set the add image to nil. You should be able to post fine.
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController* mySocialComposer = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySocialComposer setInitialText:#"Hellooooooo World"];
[mySocialComposer addImage:nil];
[self presentViewController:mySocialComposer animated:YES completion:nil];
[mySocialComposer setCompletionHandler:^(SLComposeViewControllerResult result){
NSString *outout = [[NSString alloc] init];
switch (result) {
case SLComposeViewControllerResultCancelled:
outout = #"Post Canceled";
break;
case SLComposeViewControllerResultDone:
outout = #"Post Successfull";
default:
break;
}
As per Apple's official documentation on SLComposeViewController you will see that it says
Return Value
Returns a Boolean value indicating whether the text was successfully set.
Discussion
This method returns NO if text does not fit in the currently available character space or if the view controller has already been presented to the user (and therefore cannot be changed). Character limits are dependent on the target service and are documented by the service provider. For links to documentation for the supported services, see “Table 1Social Services Individual Documentation Sites” in SLRequest Class Reference.
So if this controller has already been shown it is not going to work. Try a different text and see again.
Can you remove
mySocialComposer = [[SLComposeViewController alloc]init];
You are not supposed to do that.
[mySocialComposer setInitialText:#"Hellooooooo World"];
[mySocialComposer addImage:[UIImage imageNamed:#"image.jpg"]];
[self presentViewController:mySocialComposer animated:YES completion:nil];
Put these lines of code after you set your completion handler.
Also remove the UIAlertView from there and put it inside the completion handler for error case.