-1

I have a question regarding HTTP posting and NSURL connections.

I am basically trying to allow a user to submit their username and password within two UITextfields and then press submit and then post the data to the website to retrieve the webpage that should follow.

This link: Sending an HTTP POST request on iOS takes me through the steps of posting.

However, I don't know what to post and my main question is what exactly do I post?

Looking at the html text below, I've marked the important section where I think I've determined where the input fields are found.

The actual webpage can be found here: https://grades.bsd405.org/Pinnacle/Gradebook/Logon.aspx?ReturnUrl=%2fpinnacle%2fgradebook%2fDefault.aspx

<title>
Logon
</title></head>
<body>
<form name="aspnetForm" method="post" action="Logon.aspx?ReturnUrl=%2fpinnacle%2fgradebook%2fDefault.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
<div>


//*********************Important Part**************


<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTkxNzI3MDIzD2QWAmYPZBYCAgMPZBYGAgEPZBYCAgkPZBYCAgEPZBYIAgMPFgIeB1Zpc2libGVoZAIFDxYCHwBoZAIHDxYCHwBoZAIJDxYCHgVzdHlsZQUjdmVydGljYWwtYWxpZ246bWlkZGxlO2Rpc3BsYXk6bm9uZTtkAgMPDxYCHwBoZGQCBQ9kFghmD2QWAgINDxYCHgVjbGFzcwUQc2luZ2xlU2Nob29sTGlzdBYCAgEPZBYCAgEPEGQPFgFmFgEQBQ5EZWZhdWx0IERvbWFpbgUIUGlubmFjbGVnZGQCAg9kFgICEw9kFgICAQ9kFgICAQ8QZGQWAGQCBw8PFgIeBFRleHQFIFBpbm5hY2xlIEdyYWRlIDIwMTIgV2ludGVyIEJyZWFrZGQCCA8PFgIfAwU3Q29weXJpZ2h0IChjKSAyMDEzIEdsb2JhbFNjaG9sYXIuICBBbGwgcmlnaHRzIHJlc2VydmVkLmRkZP/l6irI9peZfyqpKjk3fwLuEbos" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }    
}
//]]>
</script>

<script src="/Pinnacle/Gradebook/WebResource.axd?d=MKdmk7ZC1nvFfTogGIArChQeNgmKJPcE4qzLcGnpfZJ_MwOZqxXfEQFvNKhYWoSExczePpNG2SwohpXs5S4lkWiwSEE1&amp;t=635199506789012606" type="text/javascript"></script>

<script src="/Pinnacle/Gradebook/WebResource.axd?d=QiUW-MpIGJoCa8EDLpgXqfBtbKW0jPJO_EJvZ6NQ17SDkob_qrGf6zm_PG2jBXFiWqNQe0AtpCJzCpPTspLqNV3WSqo1&amp;t=635199506789012606" type="text/javascript"></script>
<script src="/Pinnacle/Gradebook/WebResource.axd?d=bFqtqAFaC83zj7YLREFMNw9QVufpzfSZwdn4cGXXtEIwjMANvD40JtS6bauz35cz3GQJdZmtseUAd1OZ4R1Qi84k_0I1&amp;t=635199506789012606" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>

<div>

    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBgKjnbqUCQLnksmgAQKTpbWbDgLB5+KIBAL4xb20BAK20ZqiCel6sQLBsF1W3XHOxpgq+tJj+Rx2" />
</div>
    <script type="text/javascript" src="/Pinnacle/Gradebook/Scripts/Dialog.js?14.4.2.7">
</script>
<script type="text/javascript" src="/Pinnacle/Gradebook/Scripts/Timer.js?14.4.2.7">                 
</script>
<script type="text/javascript" src="/Pinnacle/Gradebook/Scripts/Search.js?14.4.2.7">         
</script>
<script type="text/javascript" src="/Pinnacle/Gradebook/Scripts/Watermark.js?14.4.2.7">
</script>
<script type="text/javascript" src="/Pinnacle/Gradebook/Scripts/AdvancedSearch.js?14.4.2.7"></script>
<script type="text/javascript" src="/Pinnacle/Gradebook/Scripts/Header.js?14.4.2.7">
</script>

<link rel="stylesheet" type="text/css" href="/Pinnacle/Gradebook/Styles/Header.css?14.4.2.7" />
<link rel="stylesheet" type="text/css" href="/Pinnacle/Gradebook/Styles/Nav.css?14.4.2.7" />

Community
  • 1
  • 1
waylonion
  • 6,866
  • 8
  • 51
  • 92
  • Frustrating but true: You need to take the time to study and learn. You can also use a network analyzer such as Charles Proxy to examine exactly what is being sent and received--well worth the time. – zaph May 02 '14 at 01:34
  • Yes, I've spend 5 days on this now. Do you recommend any good, reliable sources for where I can begin? Thank you. – waylonion May 02 '14 at 01:35

1 Answers1

2

I gather from your other question that you don't have access to the source code or to the web developers. That's the only way to accelerate this process.

In the absence of that, this will be a laborious process of

  1. Doing the requests in web browser;

  2. Observing with Charles, looking at the HTML you received from the server and reverse engineer what's going on (e.g. you can quickly see that these cryptic _EVENTVALIDATION, PageUniqueId, and _VIEWSTATE values that are included in the original web page you received in your initial GET request from Login.aspx);

  3. Then figuring out how to parse the HTML to get the pieces of information you need (e.g. sometimes you can get away with regex, but proper implementation probably entails HPPLE; see Wenderlich's article on parsing HTML);

  4. Writing the code that issues a request (e.g. the GET request for the initial Login.aspx page, parses the response (as outlined in point 3, above), and figures out how to take that had create the response you observed in point 2, above (e.g. as I pointed out in your other question, you have to percent escape these values).

You then may find yourself repeating these four steps for each phase of the user interaction with the web server. It can be a slow and laborious process, depending upon the complexity of the server.

Community
  • 1
  • 1
Rob
  • 415,655
  • 72
  • 787
  • 1,044