SA_OAuthTwitterEngine Twitter authentication on iOS 5 (error -1012) - iphone

I'm using SA_OAuthTwitterEngine and it works fine for some accounts. But, gives (NSURLErrorDomain error -1012.) for some twitter accounts.
It seems to work fine on ios 4. But not on iOS 5. anyone notices this problem?
Any hints?
Thanks

Yes... Change http to https in the initOAuthWithDelegate method inside SA_OauthTwitterEngine.m and this should fix the problem - like so:
self.requestTokenURL = [NSURL URLWithString: #"https://twitter.com/oauth/request_token"];
self.accessTokenURL = [NSURL URLWithString: #"https://twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: #"https://twitter.com/oauth/authorize"];

try find&replace http://twitter.com/oauth/ with https://twitter.com/oauth/
3x

#NSDestroyer is correct. Just ran into this today, and changing to https solved the issues. Thanks!

Related

how to open url need username and password with uiwebview?

I want to open an URL which need password and username in a UIWebview. Such as open my local Wifi Router(192.168.1.1). But when I try following code, there is no popup as Safari to require password and username.
NSURL *url = [NSURL URLWithString:#"http://192.168.1.1"];
NSURLRequest *httpReq = [NSURLRequest requestWithURL:url];
[self._webView loadRequest:httpReq];
Since someone told me to use NSURLConnectionDelegate, I know this, but I donot know how to show the authorized page to the UIWebView.
This will help
NSURL *url = [NSURL URLWithString:#"http://username:password#192.168.1.1"];
NSURLRequest *httpReq = [NSURLRequest requestWithURL:url];
[self._webView loadRequest:httpReq];
You need to implement connection:didReceiveAuthenticationChallenge: in NSURLConnectionDelegate. For details, read Authentication Challenges chapter from Apple "URL Loading System Programming Guide".
UIWebView doesn't provide any mechanism to identify the response. So one solution is explained in UIWebViewHttpStatusCodeHandling github project which identifies the status code of the response (should be 404 in your case).
However, the main drawback is for each request you need to use NSURLConnection and load the request again. But in this case, you can cancel the NSURLConnection too.
The other solution should (might) be the use of Java-Script. Search for the Java-script, which provides the status code of the response.

Inconsistency with MGTwitterEngine for iOS?

Before, MGTwitterEngine was working perfectly for me, but now everytime I login, i get an invalid url exception from OAuth. I thought it was because i changed something but when I tried logging in from the iphone simulator, it worked (i was trying from my iphone). I then tried an old copy of my project from 3 days ago when i had absolutely no problem, and now i'm getting the same url error. Has anybody encountered this?
To temporarily fix this, I went into SA_OauthTwitterEngine.m and did
- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate {
if (self = (id) [super initWithDelegate: delegate]) {
self.requestTokenURL = [NSURL URLWithString: #"http://twitter.com/oauth/request_token"];
//self.accessTokenURL = [NSURL URLWithString: #"http://twitter.com/oauth/access_token"];
self.accessTokenURL = [NSURL URLWithString: #"https://api.twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: #"http://twitter.com/oauth/authorize"];
}
return self;
}
There was a problem with the http://twitter.com/oauth/access_token url so I changed it to https://api.twitter.com/oauth/access_token which was in the documentation for the twitter API. It just feels uncomfortable having to alter this since it seems to be working fine for everybody else.
Any help is appreciated
As you can see on https://dev.twitter.com/docs/api/1/post/oauth/access_token,
Twitter recommends using HTTPS instead of HTTP, so even if it worked many times before you changed to HTTPS, don't feel uncomfortable! Sometimes, a line of code works well, but another one works better. There's nothing uncomfortable in it !
Please use HTTPS for this method, and all other OAuth token
negotiation steps.
Resource URL https://api.twitter.com/oauth/access_token
Hope it answers your question.

WebView Failed error in iPhone

I am trying to load website in webview.But i am getting error. Please correct me where i am wrong
URL : http://www.facebook.com/pages/Fresh-Caesar/144860502248864
Error : The operation couldn’t be completed. (WebKitErrorDomain error 101.)
We can resolve this problem by using string encoding
NSString *encodedString=[siteUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *weburl = [NSURL URLWithString:encodedString];
Maybe look at WebKitErrorDomain error 101 for reference. Need to see more of your code though. Can you provide listing?

Direct "rate in iTunes" link in my app?

I've seen posts here on Stackoverflow that describe how to allow users to be directed to apps on the app store.
Is there a way to link directly to the rating and comments form in the App Store?
This IS possible using the technique described on this blog:
http://www.memention.com/blog/2009/09/03/Open-Reviews.html
basically you call UIApplication openURL with the following:
NSString* url = [NSString stringWithFormat: #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%#", myAppID];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
To get your app ID before your app is available in the app store, use iTunesConnect to define your new app - give it a name, description, icon, screenshots, etc. Once defined, you can get the Apple ID from the Identifiers section for the app.
EDIT:
Here is a secondary url/method that works:
NSString* url = [NSString stringWithFormat: #"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%#&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8", appid];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url ]];
I believe the difference between the two is that the first technique (itms-apps://) will launch the App Store app directly while the second one (http://) will launch it indirectly via a redirect resulting from the http web URL. This would have to be confirmed; this is only my recollection.
Answers here are outdated.
This works on my end (Xcode 5 - iOS 7 - works only on Device, not simulator!):
itms-apps://itunes.apple.com/app/idYOUR_APP_ID
For versions lower than iOS 7 use the old one:
itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=YOUR_APP_ID
Simple method that I am using is;
-(void)rateApp {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[#"itms-apps://itunes.apple.com/app/" stringByAppendingString: #"id547101139"]]]; }
You can also use SKStoreProductViewController as an alternative. It will open the store in your app. You may like it better than opening another app, especially on iPads.
Thanks to Ahment swift version:
UIApplication.sharedApplication().openURL(NSURL(string: "itms-apps://itunes.apple.com/app/id951334398")!)

how to send e-mail without MFMailComposeViewController in iOS?

How to redirect to mail application from iPhone application?
I have seen in Stack Overflow like MailComposerViewController.
They are sending email from within the iPhone application. But I want to quit project and redirect it to in-built Mail app Which is in iPhone?
How can I do this?
I have tried the following. Are there any frameworks required for this?
- (IBAction)ddd:(id)sender
{
NSString *_recipient = #"someone#email.com";
NSURL *_mailURL = [NSURL URLWithString:[NSString stringWithFormat:#"mailto:%#?subject=My Subject", _recipient]];
[[UIApplication sharedApplication] openURL:_mailURL];
}
No, there are plenty of stackoverflow posts on how to send e-mail without MFMailComposeViewController. In fact, there was at least one response to your request 16 hours earlier that would quit your app and start Mail
Here's how I do it in my apps, copied exactly as it is:
-(IBAction) mailForHelp:(id)sender
{
NSString *urlStr = [NSString stringWithFormat:#"mailto:info#BitsOnTheGo.com?subject=NumMemorize Question"];
NSURL* mailURL = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL: mailURL];
}