Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to create this google script code that'll help me acquiring some information, however, when I'm fetching the web pages I want, it fails because of the Authentication.

The website itself doesn't have any APIs, and no OAuth.

basically what I need to do is call this function:

function testlogin() 
{
var var1 = 'Email' ;    
var var2 = 'Password' ; 
if( validationLoginForm(var1,var2 ) ) { 
    document.loginForm.action="/login.do";  
    document.loginForm.method="post";
    document.loginForm.submit();    
    return true;
} else { 
    return false; 
} 
}

// Validation For Login Page. ( login.jsp)
function validationLoginForm(var1, var2){

// For User name 
validatorForMandatoryField(document.loginForm.userName ,var1);
// For Password
validatorForMandatoryField(document.loginForm.password ,var2);

// Get the any alert message.
if ( getAlertMsg()!= '' ) {
    alert( getAlertMsg() );
    alertMsg = '';
    if(field != ''){
                focusField = field;
                focusField.focus();
    }
    field = '';
    return false;
}
return true;

}

This function is present over the website I'm accessing, myaiesec.net and I want to give it an Email and password to "act" as if I logged in over my Google script shown below.

function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A2");
var id = range.getValue();
//login here
var response = UrlFetchApp.fetch("http://www.myaiesec.net/exchange/viewtn.do?operation=executeAction&tnId="+id);
sheet.getRange("C2").setValue(response);

}

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.