I am using an url in HTTPS mode. Now I need to parse this url link using NSXMLParser. I tried to parse it but am getting this error "Unable to download story feed from web site(Error code 5)". Is it possible to parse a https url? Why am getting this error? Is there any sample code or links? Kindly help me to get out of this. Thanks in advance.
Not sure to understand, but if you've got an URL as a string, you can create a NSURL object with the urlWithString: method.
NSURL * url = [ NSURL urlWithString: #"https://www.example.org/foo/bar.html" ];
Then, you'll have access to all URL parts, using the NSURL methods, like host, path, scheme, port, and so on...
Related
I am using SA_OAuthTwitterController api for integrating twitter. While I try to post the tweet using
[_engine sendUpdate:tweetTextField.text]
my app crashes. I am getting the error:
Authenicated for (null).
Also My stack after crash shows me:OAMutableURL Request URL encoded string. what the problem ?
From the limited amount of information given it seems that no user has been authenticated. You may authenticate the user with a different instance of _engine which would be causing a crash.
and also may your URL not encoded with string here bellow some characters encode code define in bellow link after use this code in your URL if special characters are use...
http://www.w3schools.com/tags/ref_urlencode.asp
and also for encode the NSURL just use bellow code...
NSString* escapedUrlString =
[unescapedString stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding];
hope,this help you...
:)
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.
I have just read different stuff about NSXMLParser, NSURLConnection, WebKit and more, but I don't know how to do this: I have a URL to a website and I would like to get the source of this website to read and later store relevant information.
Some guidance to the right direction would be appreciated, Fabian
To get your HTML, all you have to do is use a NSURLRequest to make a request to your website, then use the NSURLConnection to issue the request, this will return with some data that is the html source, from there you can do what you wish. I am going to post an example of how to make a request synchronously, just be aware that you probably want to do this async...Also here is a ref to NSURLRequest
NSURL *yourURL = [NSURL URLWithString: urlstring ];
NSURLRequest *request=[[NSURLRequest alloc] initWithURL:yourUrl];
NSData* data=[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
//now you can use the data and the websites encoding to get a string
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.
I have this question that is unsolved for me.... I need to check if the current URL of my webview is a local file in the Documents directory of my app....how can I do this??
Thanks!
You can check:
[request.URL isFileURL];
More information here.
Check the URL's scheme. Assuming you have an NSURL* instance called myURL:
if ([[myURL scheme] isEqualToString:#"file"]) {
NSLog(#"URL %# is local", myURL);
}
Read Apple's NSURL specification to learn more about accessing different parts of an URL.
Assuming you have a UIWebView* called myWebView, you might call something like:
[[myWebView request] URL]
to get the NSURL* of what the web view currently has loaded. Then you can call that object's scheme as described above.
Check for the file:// protocol in the URL.