Use MATLAB's webread to login to website and extract text - matlab

I'm wondering how to extract text from a password protected website using Matlab's "webread" function. I have the following code (part of which i got from here):
values=inputdlg({'Url','Username:','Password'});
options=weboptions('Username',values{2},'Password',values{3},'Timeout',Inf);
html=webread(values{1},options);
txt = regexprep(html,'<script.*?/script>','');
txt = regexprep(txt,'<style.*?/style>','');
txt = regexprep(txt,'<.*?>','');
But it gets stuck at the login window for every webpage I've tried. Help? Ideas? Thanks.

The weboptions username and password parameters are for basic HTTP authentication, which is different than logging into Stack Exchange, Gmail, etc though the username and password boxes on a web page.
Some sites provide other mechanisms that might allow you to log in (like OAuth), and the File Exchange has a smattering of clients.

Here is an OAuth interface for login into the flicker using Matlab, maybe it help you. but you have to be sure that your website support this authentification method (as "Matt Krause" mentioned in his answer).
Link to Tutorial

Related

Facebook OAuth SSO Issue

I have a JavaEE Application. I am trying to implement OAuth.
But I am facing some strange issues:
As per the documentation to manually building the sign in web flow I have to provide a link like this https://www.facebook.com/dialog/oauth?client_id=1231298371123&display=popup&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fc%2Fportal%2Fauth%2Ffacebook_login%3F&scope=email,public_profile,user_birthday&response_type=code%20token which will open the dialog. But the dialog is not opening.
And when the SSO is successful FB is redirecting to the url given above but the problem is FB is appending the query strings like state, code, etc with #. Something like: http://localhost:8080/c/portal/auth/facebook_login?#state=ASDASDASDASD&access_token=EAANXZAlBTi........ Because for this I cannot get the parameters in Java.
Do any one came across this kind of issue.
Please help.
Not sure if I understood the question right but if you want to read the string after # you can use the following code
URI uri = new URI("http://test.com/#something=some");
String fragment = uri.getFragment();
fragment will be everything after #

MVC 5 facebook/google authentication, without email

I implemented Facebook/Google authentication according to this article:
http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on, but after authentication users are prompted to input their email address. Is there any way to authenticate the user without asking for their email? I'm pretty sure many sites do that. Any guidance or article appreciated!
In AccountController in the function ExternalLoginCallback replaced the line
return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email });
with all the lines inside the function ExternalLoginConfirmation

PowerShell Script and Form Authentication

I have a PowerShellScript that will call a webpage and the webpage is doing some code-behind work. The issue I am trying to resolve is that I'd like to make the webpage as a secured web page, but once I do that, I couldn't figure out a way to pass the username and password to the secured webpage from PowerShell Script. I am using the form authentication. I'd appreciate if anyone could provide a completed code sample so that I can just plug-in and do the magic. Thanks so much!
p.s. I've already tried the System.Net.NetworkCredential, but it seems it is for the basic authentication.
$url = "someurl"
$webclient = New-Object System.Net.WebClient
$webclient.DownloadString($url)
Need a little more information. You may be able to solve your issue with the following answer
How to post data to specific URL using WebClient in C#
But I'm curious, what page you are submitting your authentication form to? That page would have this information. If the form is returning data into PS variables. Then the above link shows how to post directly to a page

Typo3 login password hash

How can I build the rsa hash of the Typo3 login in php manually? I need to create a spider script which just goes to every site, and the problem is therefor I have to be logged in. So I thought I do the loggin via CURL. But then I saw this rsa hash of the password and now I don't know how to convert a password like "blablabla" into such a rsa hash.
Can anyone help me?
You might find some help out of auto login extension here: http://typo3.org/extensions/repository/?id=23&L=0&q=auto+login
Or debugging tx_rsaauth_sv1::authUser. An RSA-decrypt function is called there. However I don't have the time to really dive into it right now.
Another solution is to login once and save the cookies. Then send those cookies with your CURL request.
To make the cookies valid for a longer period, you could temporarily change the backend session time-out setting before logging in. Like so:
$TYPO3_CONF_VARS['BE']['sessionTimeout'] = strtotime('+1 year')-time();
You can add/change this line in typo3conf/localconf.php (Typo3 < 6) or typo3conf/AdditionalConfiguration.php (Typo3 6+).

Codeigniter Facebook app POST method AND query_string

I have a toy facebook app I'm playing with so I can understand how it all works. It's fine if you go the the app like this: http://apps.facebook.com/pushup-challenge/ (and connect it). But if you then go to it from your facebook page, FB uses the URL http://apps.facebook.com/pushup-challenge/?ref=bookmarks.
In my log file, I see that FB is POSTing the data and including the /?ref=bookmarks to it's call to my codeigniter system. This is causing it to either say "invalid URI parameters" or give me a 404, depending on if I've edited the system/core/URI.php file to add rawurlencode() to a particular call.
I've tried using mod_rewrite to get rid of the query_string, too, but since it's POSTing, it doesn't appear to be working (though I'm not exactly sure why).
Has anyone else run into this? How did you fix it?
Thanks in advance,
Hans
try $config['uri_protocol'] = “PATH_INFO”; and set enable_query_strings = TRUE
or
set
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?=';
in config.php
Because it isn't calling your file by name (just ?ref=bookmarks) the server runs thru the standard default files: index.htm, index.html, index.asp. Because you need to accept a POST, you need a server that allows POSTs to htm & html if you choose to use those. Index.asp will accept POSTs on most servers, and that works for me.
SOLUTION: Add a file (index.asp), that calls the real app that you named in the App settings.