ShareKit twitter 403 (unknown error) - ios

I'm using ShareKit to share through FB and twitter. I'm using this code to share to twitter:
- (IBAction)twitterShare:(id)sender {
// Create the item to share (in this example, a url)
NSURL *url = [NSURL URLWithString:[flexViewController shareURL]];
SHKItem *item = [SHKItem URL:url title:[flexViewController shareText]];
[SHK setRootViewController:self];
// Share the item
[SHKTwitter shareItem:item];
}
I'm getting "403 Forbidden:The server understood the request but is refusing to fulfill it". This always happens if the login view was prompted. If the user was already logged in from an earlier session (the app was closed and reopened), it works correctly.
In this page, it declares that 403 means I have reached a limit, which I don't think it's my case.
https://dev.twitter.com/docs/error-codes-responses
The above code worked correctly last week, but now I'm getting this error.

Ran into the same issue using the old version of ShareKit and was able to solve by editing the Twitter URL in the following section of SHKTwitter.m.
- (void)sendStatus
{
OAMutableURLRequest *oRequest = [[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:#"https://api.twitter.com/1/statuses/update.json"]
The URL was different in the ShareKit 2.0 version.

Related

Pinterest error invalid sdk client key ios

I am implementing Pinterest in my app.My code is as follows:
pinterest = [[Pinterest alloc]initWithClientId:#"Myapp_ClientID"];
NSURL *imageURL = [NSURL URLWithString:#"http://7-themes.com"];
NSURL *sourceURL = [NSURL URLWithString:#"http://7-themes.com/data_images/out/42/6914793-tropical-beach-images.jpg"];
[pinterest createPinWithImageURL:sourceURL
sourceURL:sourceURL
description:#"Pinning from Pin It Demo"];
I registered app and got client id which I put in my code but when run on device it always give me error invalid client id
You are giving the Client key wrong. (Which should be obvious). Most likely this question will be taken off but let me help you anyways:
pinterest = [[Pinterest alloc]initWithClientId:#"Myapp_ClientID"];
On the above line you are giving the client key wrong. Sdk client keys are long and with alternating Alpha numeric characters to enhance security. What you are doing is, you are passing it a string which holds the value Myapp_ClientID. So your operation is aborted.
If you have declared Myapp_ClientID as a constant or it is a variable of corresponding type, then simply use this line:
pinterest = [[Pinterest alloc]initWithClientId:Myapp_ClientID];
Else provide the correct client key like:
pinterest = [[Pinterest alloc]initWithClientId:#"Your client key here"];

Custom Login Instagram API iOS

I'm developing an application for iOS with the authentication, using Instagram API.
My code for authentication works good:
NSString *fullURL = [NSString stringWithFormat:#"https://instagram.com/oauth/authorize/?client_id=%#&redirect_uri=%#&response_type=code",KCLIENTID,kREDIRECTURI];
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
instagramConnectWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];
instagramConnectWebView.delegate = self;
[instagramConnectWebView loadRequest:request];
When the request is sent, my webView shows the standard Instagram login interface, where user has to insert username and password to login. If login succeed, app is redirected to my redirection-url, where i get the code and the token of this user.
My question is really simple, is there a way to customize standard interface of Instagram login? I'd like to insert in my app two simple UITextField (One for username and one for the password) and when user clicks on my UIButton login, application should send (POST or GET?) username and password to Instagram, and return response (Login success or not).
I hope i explained myself.
Thanks.
You can make this by using javascript. by loading a web view in background :
You need to access the text field of that web view and pass value of your custom UItextfields and after that you can call webView's "Submit" button's Onclick event.
NSString *javaScript = #"document.getElementById('id_username').value = 'tfusername'";
NSString *javaScript2 = #"document.getElementById('id_password').value = 'tfpassword'";
to evaluate each script you can call: [webView stringByEvaluatingJavaScriptFromString:javaScript];
You can also call script to press login button. This same thing work for me. May be this will help you.
I have created a wrapper for Instagram API for iOS. Take a look at this link . This will also give an idea of what you need to do.

Error code 2500 when requesting facebook picture

I am using the social framework and the accounts framework to access facebook from my app. In one line of code I do:
NSURL *meInfo = [NSURL URLWithString:#"https://graph.facebook.com/me"];
Which is successful. I get a json object with me data which I can then use in my app. Confusingly, in the very next block of code, I do this:
NSURL *meInfoPic = [NSURL URLWithString:#"https://graph.facebook.com/me/picture"];
And it fails with:
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
My access token is obviously valid, so I am not sure what is going on. The permissions I am using for both are "publish_stream". Any advice?
My mistake was using /me/ in the picture request URL. Once I replaced that with the user id for the logged in user I got further. So to be clear, I needed to do this:
NSURL *meInfoPic = [NSURL URLWithString:#"https://graph.facebook.com/123456789/picture"];

iOS- sharekit - settings facebook

I have a sharekit implementation where everything works fine, but if there is no account set for facebook, upon pressing the settings button, the actionsheet is just dismissed and the user is returned to the app, not to the settings page in system prefs.
How do I get the settings button to send the user to the settings page?
the code i use to init the action sheet:
NSURL *url = [NSURL URLWithString:#"http://test"];
SHKItem *item = [SHKItem URL:url title:#"test"];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// Display the action sheet
[actionSheet showFromTabBar:self.tabBarController.tabBar];
This is a known, unresolved issue with ShareKit. You could submit a pull request to fix it, or work around it by checking SLComposeViewController:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
// show ShareKit
} else {
// tell them to get Facebook
}
before displaying ShareKit. Of course, that would make it so users without Facebook (like Twitter-only folks) couldn't use ShareKit. On the other hand, you could switch over to Apple's Share Sheets, or write your own, but those also have their disadvantages. Kind of a catch-22.

ios-Facebook SDK 3.0 Error 5 When Posting Status Update

I am trying out adding facebook integration in an app using the new (beta) facebook ios sdk 3.0. All I would like to is post a status update to facebook. I used a FBLoginView to login to facebook. I put my app id in the plist as instructed on facebook. I put in some code to post to facebook.
(void)viewDidLoad
{
[super viewDidLoad];
NSArray *perms;
perms = [NSArray arrayWithObjects:#"status_update", nil];
FBLoginView *loginview =
[[FBLoginView alloc] initWithPermissions:perms];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)poststatus:(UIButton *)sender {
NSString *message = [NSString stringWithFormat:#"Test staus update"];
[FBRequestConnection startForPostStatusUpdate:message
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
}];
}
- (void)showAlert:(NSString *)message
result:(id)result
error:(NSError *)error {
NSString *alertMsg;
NSString *alertTitle;
if (error) {
alertMsg = error.localizedDescription;
alertTitle = #"Error";
} else {
NSDictionary *resultDict = (NSDictionary *)result;
alertMsg = [NSString stringWithFormat:#"Successfully posted '%#'.\nPost ID: %#",
message, [resultDict valueForKey:#"id"]];
alertTitle = #"Success";
}
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:alertTitle
message:alertMsg
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}
The odd thing is, this code works ONCE. After authenticating the user for the first time, I can post ONE status update successfully. After that, all subsequent attempts will fail with a FBiOSSDK error 5 (in the console, Error: HTTP status code:400). The only way to fix this is to remove the app from the facebook account and re-authenticate. I'm not sure what the problem is. I looked online for solutions but couldn't find anything. If anyone knows how to fix this, please let me know. Thanks
com.facebook.sdk error 5 is always irritating while working with Facebook iOS sdk. Most of the times it comes with addional in console Error: HTTP status code:400. Its a perception that there is a bug in Facebook iOS sdk that produces this error randomly. I think this error occurs for some certain reasons and sdk do not provide actual reason of error when it occurs.
Several Possible Reasons
Every request in sdk is accomplished with completion blocks that we actually pass as argument in completionHandler. This error occurs when a block is in progress and made another request. A simple example might be If you have written request to post on Facebook (startForPostStatusUpdate::) on some button action. On single button tap it would work fine but if you double tap on button it will throw this error com.facebook.sdk error 5
If you are trying to post when your current session is not opened. e.g. Once sign in with Facebook then kill the app then reopen and then try to share on Facebook, Result -> com.facebook.sdk error 5. In this case try to reopen session using
Facebook do not allow same status to be posted repeatedly, they think it might be some kind of spam e.g. If you are trying to update status and you have hard coded a string lets say #”This is a test status update” you are posing again and again. After 5 to 10 attempts they wont allow you to do anymore. Resulting com.facebook.sdk error 5. If this is the scenario you should change your status string and try updating.
Facebook has defined a limit for a particular user to post status using sdk. e.g If you are trying to update status and you have done lets say 15 to 20 status updates. They wont let you do more Resulting -> com.facebook.sdk error 5. In this scenario try to unauthorize the app from your Facebook account and reauthorize it OR try using other Facebook account
It seems there might be no answer to the issue. I have checked FB samples coming with SDK, in these examples also the same error happens. So it means after few status updates (15-20) Facebook reaches limits for that particular user. If you log-out for that user and log-in as another user, you can successfully post.
If I will find any extension to limit settings I will reply.
Also Facebook doesn't allow for the same Post.
Use a proxy !
FB ios SDK is just a wrap to an HTTP request to graph.facebook.com/....?access_token=.....
So you can easily replicate the request or use an HTTP proxy to see the real server answer (which is not error 5 !).

Resources