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.
Related
I'm wanting to integrate Twitter and Facebook into a game using Cocos2D. I just want simple stuff like tweeting "I scored xxx", posting similar message to Facebook page, etc. I've seen numerous libraries offering to make my life easier - ShareKit, AddThis, etc - but I've also read things from people saying they are not that easy, not supported, and so on.
I could just go and get the facebook and twitter SDKs and integrate them in, but I was wondering if anyone had any recommendation for something that I've missed. I need to support iOS4 and 5 so I the library should use the built-in twitter features in iOS5 if present I guess.
Any suggestions or comments on this - perhaps I've just missed something really obvious?
You can share on Facebook by simply inserting the following line of codes.
For twitter I think there isn't exists such an easy way.
NSString *urlString = #"any url";
NSString *title = #"My score is 999";
NSString *shareUrlString = [NSString stringWithFormat:#"http://www.facebook.com/sharer.php?u=%#&t=%#", urlString , title];
shareUrlString = [shareUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [[NSURL alloc] initWithString:shareUrlString];
[[UIApplication sharedApplication] openURL:url];
[url release];
You can share on twitter using following code
twt = [[TWTweetComposeViewController alloc] init];
[twt setInitialText:#"Scorred 1000"];
[twt addURL:[NSURL URLWithString:#"url"]];
twt.completionHandler = ^(TWTweetComposeViewControllerResult result) {
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
[twt dismissModalViewControllerAnimated:TRUE];
break;
case TWTweetComposeViewControllerResultDone:
//[self.navigationController popViewControllerAnimated:NO];
[self.navigationController popViewControllerAnimated:TRUE];
break;
default:
break;
}
[twt dismissModalViewControllerAnimated:TRUE];
};
1) For Facebook,Ofcourse you can use facebook SDK and configure it https://github.com/facebook/facebook-ios-sdk . But You may get lots of questions in that. Better read documentation given in facebook website and do it. Feel free to ask any doubt in that.
2)For Twitter, you can use twitter framework which is inbuilt in ios5. Its pretty easy. Try to use tweet sheet in that. It will give a good experience and consistency to the users of ios5.
But You also have to integrate MGTwitterEngine( https://github.com/mattgemmell/MGTwitterEngine ) to give support for ios4 and and its prior versions. Its little difficult.
Hope You got it.
I made some tutorials for a facebook and a twitter helper Class I hope it helps... http://ludosimagos.tumblr.com/
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!
I know this has been asked before but I have looked at every answer (there aren't many) and none help me.
The issue I am running into is dealing with certificates with my schools e-mail service. The links for the two e-mail services are here:
Main school e-mail:
https://marauder.millersville.edu/mail/index.pl
Computer Science e-mail:
https://cs.millersville.edu/cswebmail
University student portal (Marauder Mail button on the right doesn't open when clicked in my UIWebView)
http://myville.millersville.edu/
At first neither of the websites would load in my UIWebView using a standard NSURL and NSURLRequest. I looked
on the web for a solution and someone suggested using the NSURLProtocolClient delegate methods. After
implementing them, my UIWebView will now load the schools mail e-mail ONLY when I have a button that when
clicked opens the link directly, as opposed to trying to access the mail from the portal site (3rd link above), and it
still never loads the computer science e-mail link. I have scoured the iOS help sites, posted questions, tried
multiple open-source custom UIWebViews, but I have not found anything that works.
Most answers I have read around the web point to ASIHTTPRequest. I have tried this but I cannot implement it right, it doesn't load the links in my UIWebView; here is my code for how I am loading a link:
mURL = [self getURL:viewNumber];
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:mURL];
[req setDelegate:self];
[req startSynchronous];
//NSURLRequest *req = [NSURLRequest requestWithURL:mURL];
//urlConnection=[[NSURLConnection alloc] initWithRequest:req delegate:self];
webView.scalesPageToFit = YES;
//[webView loadRequest:req];
Code in comments is how I load a link without ASIHTTPRequest.
Any help is appreciated!
Also, I have another issue with my UIWebView, link is below. I haven't had any answers so if you're bored please check it out:
UIWebView doesn't detect text box on website
Fixed my issue, I was able to load https with no problem with the following code I didn't think this would work but it does!:
NSURLRequest *req = [NSURLRequest requestWithURL:mURL];
urlConnection=[[NSURLConnection alloc] initWithRequest:req delegate:self];
webView.scalesPageToFit = YES;
[webView loadRequest:req];
Web view does not load https urls due to certificate mismatch. After writing this extension it would work as expected
Swift 2.2
extension NSURLRequest {
static func allowsAnyHTTPSCertificateForHost(host: String) -> Bool
{
return true
}
}
I'm trying to track an event in my app using Yahoo Web Analytics. The code I am using looks like
ASIHTTPRequest *yahooTrack = [ASIHTTPRequest requestWithURL:
[NSURL URLWithString:#"http://s.analytics.yahoo.com/p.pl?a=xxxxxxxxxxxxx&js=no&b=yyyyyyyyyyyy&cf6=zzzzzzzzzzz"]];
yahooTrack.didFinishSelector = #selector(statisticsFinished:);
yahooTrack.delegate = self;
[yahooTrack startAsynchronous];
Then the statisticsFinished looks like:
NSLog(#"Cookies: %#", request.requestCookies);
NSLog(#"Redircount: %d", [request redirectCount]);
NSLog(#"Responsecode %d %#\nMsg: %#", request.responseStatusCode,
request.responseStatusMessage, [request responseString]);
And all the information I get back looks correct. Cookies are set, redirectcount is 1 the first time (as it redirects to s.analytics.yahoo.com/itr.pl?.... a normal browser does). Then the redirectcount is 0 for subsequent request until the app is restarted and session cleared. The responseString returns GIF89a.
Even if the data looks correct, Yahoo still won't track. As soon as I call the tracking url directly in my browser it works as expected.
I realize Flurry is a better option, but I'm forced to use Yahoo in this case. Also, using a UIWebView probably would work, but I'm against putting in a webview just for tracking purposes.
Is there any difference in how ASIHTTPRequest and Safari would handle a call to a simple URL as this? Or do you see anything else that could explain why the tracking isn't working?
I finally found the problem. ASIHTTPRequest creates a user-agent based on your applications name, and requests from this user agent is ignored by Yahoo somehow (bug?). As stated in the documentation, you can override the user-agent as follows:
[request addRequestHeader:#"User-Agent" value:#"My-User-Agent-1.0"];
I used the user-agent string of Safari on iPhone, and it worked immediately! BTW; the same problem applies for Android, and the same fix works.
I've got an app that I want to be able to use Custom URL schemes for. I want users to be able to open Tweetie using the Custom URL protocol however I need to populate the tweet with dynamic website link which I get using currentItem.link.
I found this code which launches Tweetie and populates a message with static information:
NSString *shortened_url = #"http://your.url.com";
NSString *stringURL = [NSString stringWithFormat:#"tweetie://%#", shortened_url];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
So using the above code how would I populate the message with currentItem.link information?
Thanks.
It depends entirely on the application on the receiving end. You have to find out how their protocol works, then you can use their protocol as it is designed.
Adding a http:// protocol URL to the end of a tweetie:// protocol URL is not the correct method, and searching for how the Tweetie URL protocol works would be suggested.
The Tweetie protocol is documented, but it's not clear how much of this still applies since the client was converted to the official Twitter one. I believe that the format you want is:
NSString *stringURL = [NSString stringWithFormat:#"tweetie://post?message=%#", shortened_url];
I have already tried this to get the account selection parameter to work. The basic method works, but account selection does not for me.