Logging into https://www.amazon.com/ap/signin with PhantomJS - javascript

Maybe I am making this more complicated then I need to. I am learning about Phantom JS I figured I could use that to automate Android App submissions to the Amazon App Store/Amazon Developer Console. The login page has this URL: http://developer.amazon.com/home.html
It redirects to a super long URL and presents a form to enter one's username and password and a button to click. If you look at page source you see a form that has all sorts of hidden inputs. Here is the part of the actual form tag from the page source:
<form name="signIn" method="POST" id="ap_signin_form" novalidate="novalidate" action="https://www.amazon.com/ap/signin" onsubmit="var test1 = apCheckRequiredFields('ap_signin_form', ['ap_email','ap_password']);
return (apValidateEmail('ap_email') && test1);">
<input type="hidden" name="appActionToken" value="scIhj2FOCtxr39z7eUIj2FWeNOWxtIwj3D"><input type="hidden" name="appAction" value="SIGNIN">
<input type="hidden" name="openid.pape.max_auth_age" value="ape:MQ==">
<input type="hidden" name="openid.return_to" value="ape:aHR0cHM6Ly9kZXZlbG9wZXIuYW1hem9uLmNvbS9hcF9sb2dpbi82ODc0NzQ3MDczM0EyRjJGNjQ2NTc2NjU2QzZGNzA2NTcyMkU2MTZENjE3QTZGNkUyRTYzNkY2RDJGNjg2RjZENjUyRTY4NzQ2RDZDLmh0bWw=">
<input type="hidden" name="prevRID" value="ape:N1RBVEM3SFQxSEdXRTNITUFENEs=">
<input type="hidden" name="openid.identity" value="ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=">
<input type="hidden" name="openid.assoc_handle" value="ape:bWFzX2Rldl9wb3J0YWw=">
<input type="hidden" name="openid.mode" value="ape:Y2hlY2tpZF9zZXR1cA==">
<input type="hidden" name="language" value="ape:ZW5fVVM=">
<input type="hidden" name="openid.claimed_id" value="ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjAvaWRlbnRpZmllcl9zZWxlY3Q=">
<input type="hidden" name="pageId" value="ape:bWFzX2Rldl9wb3J0YWwy">
<input type="hidden" name="openid.ns" value="ape:aHR0cDovL3NwZWNzLm9wZW5pZC5uZXQvYXV0aC8yLjA=">
<div id="ap_signin1a_pagelet" class="ap_table ap_pagelet">
<div id="ap_signin1a_pagelet_title" class="ap_row ap_pagelet_title">
<h1>Sign In </h1>
</div>
<div id="ap_signin1a_email_section_title" class="ap_row ap_section_title">
<h2>
What is your email (phone for mobile accounts)?
... even more html here ...
I am kind of confused about what I am suppose to do with the Phantom JS code. Do I need to collect all these hidden inputs and build a form data object to send in a POST request? Or do I just need to figure out what DOM objects I need to set to my my credentials and then generate a button click event?

Related

Submit GCP POST form without changing page

I have a C# MVC website and I'm trying out Google Cloud Print(GCP) to print.
Google Provides this example
https://developers.google.com/cloud-print/docs/appDevGuide
<form action="https://www.google.com/cloudprint/submit" method="post" enctype="multipart/form-data" id="submitForm">
<input type="hidden" name="xsrf" value="xsrfTokenHere"/>
<input type="hidden" name="printerid" value="123456789"/>
<input type="hidden" name="ticket" value='{"version": "1.0", "print": {}}'/>
<input type="text" name="title" value="My Document"/>
<input type="text" name="contentType" value="application/pdf"/>
<input type="text" name="tag" value=""/>
<input type="file" name="content"/>
<input type="submit" value="Print"/>
</form>
Which does what it should.
But it sends the user to the Google website were it displays the JSON response.
Is there any way to skip this last part, e.g let the user submit the form without moving to the google website.
I've tried various jQuery AJAX and similar calls. I've also tried posting the form inside of an iframe but none of these work since Google does not allow Cross-Origin calls.
If there was a way to post this either in HTML, Javascript or C# without jumping to the google result page it would've been great.

Login to a website through html post form and navigate to another page and click an element

I have a html page with the following code which logs me in a website:
<form id="user-login" action="http://thewebsite.com/user/login/" method="post">
<input type="hidden" name="name" value="acc123"/>
<input type="hidden" name="pass" value="password"/>
<input type="hidden" name="form_build_id" value="formid"/>
<input type="hidden" name="form_id" value="user_login"/>
<input type="submit" name="op" value="Log in"/>
</form>
The post works and I'm logged in .
Next , while I'm logged in I want to execute another script on the same website but in a different page for executing a button click:
Here's how the website button is defined :
<a style="cursor: pointer; " class="vote-this" onclick="doVote(1234)">Click</a>
How I'm supposed to do this while logged in? ( to call the onclick event )
Like this? On the page you get redirected to, when you log in.
<body onload="doVote(1234)">...</body>

How to redirect opt-in form to thank you page?

I'm trying to figure out how to redirect my opt-in form to a specific page (http://www.example.com/thanks)
Here's the code for my form:
<form action="http://mailer334.insty.me/subscribe" method="POST" accept-charset="utf-8">
<label for="name">Name</label><br/>
<input type="text" name="name" id="name"/>
<br/>
<label for="email">Email</label><br/>
<input type="text" name="email" id="email"/>
<br/>
<input type="hidden" name="list" value="efwefwefwefwefwef"/>
<input type="submit" name="submit" id="submit"/>
</form>
Right now it's just taking people to the default page for Insty.me (http://mailer359911.insty.me/subscribe) which isn't what I want it to do - it need to post information to that page to add people to my email list, but redirect to a different page thanking them and giving further instructions.
Create a wrapper php script on your domain that receives the form info and then post to the
third party via CURL. Then do the redirect using
header("Location: http://www.mysite.com/thanks");
You might be thinking on submitting the form using ajax and then redirect, but that will
be impossible because the SAME ORIGIN POLICY enforced by the browsers as a security rule.
You cannot run ajax request against a different domain. On a phonegap application you might
override this behavior , but on a standard web app that is intended to be open on regular browsers is not possible.
<?php
if(!isset($_POST['submit'])) {
?>
<form action="http://mailer334.insty.me/subscribe" method="POST" accept-charset="utf-8">
<label for="name">Name</label><br/>
<input type="text" name="name" id="name"/>
<br/>
<label for="email">Email</label><br/>
<input type="text" name="email" id="email"/>
<br/>
<input type="hidden" name="list" value="efwefwefwefwefwef"/>
<input type="submit" name="submit" id="submit"/>
</form>
<?php
} else {
include 'thanks.php';
} ?>

Auto Submitted form not carrying the values into Page which is mentioned in Action attribute of <form> tag

I tried to do auto form submission.It works fine and it redirected to the action page.But,it does not carry the values.Please help me to find the solution.
<form method="POST" action="SamplePage" name="myForm" id="formone">
<input type="hidden" name="AMT" value="10"/>
<input type="hidden" name="ID" id="cust"/>
<input type="submit" value="Submit" id="bu" name="i"/>
</form>
I used document.getElementById("formone").submit(); the for auto submission.
Try like this
document.forms["formone"].submit();
or you can try like
document.formone.submit();
Where your form name should be formone
And at your action page try to access the REQUEST values
print_r($_REQUEST);

Paypal Express Checkout for digital goods request for token getting killed

Ok so I am pretty new to paypal for digital goods. I have done some extensive reading but the paypal documentation seems to a bit overwhelming and information seems a bit spread out. Basically what I need to do is to sell credits on my site and I followed the instruction on integrating digital goods for express checkout. Here is my HTML form code
<form id = "paypalForm" style = "display:none;" method="post">
<p>
<input id="submitBtn" type="submit" value="Pay with PayPal" />
<input type="hidden" name="METHOD"value="SetExpressCheckout" />
<input type="hidden" name="RETURNURL"value="http://ec2-54-244-155-132.us-west-2.compute.amazonaws.com" />
<input type="hidden" name="CANCELURL"value="http://ec2-54-244-155-132.us-west-2.compute.amazonaws.com"/>
<input type="hidden" name="PAYMENTACTION"value="sale"/>
<input type="hidden" name="PAYMENTREQUEST_0_CURRENCYCODE"value="USD"/>
<input type="hidden" name="PAYMENTREQUEST_0_ITEMAMT"value="3"/>
<input type="hidden" name="L_PAYMENTREQUEST_0_ITEMCATEGORY0"value="Digital"/>
<input type="hidden" name="L_PAYMENTREQUEST_0_NAME0"value="Deans Door Credits"/>
<input type="hidden" name="PAYMENTREQUEST_0_AMT"value="500"/>
<input type="hidden" name="L_PAYMENTREQUEST_0_QTY0"value="1"/>
<input type="hidden" name="L_PAYMENTREQUEST_0_AMT0"value="100"/>
<input type="hidden" name="REQCONFIRMSHIPPING"value="0"/>
<input type="hidden" name="NOSHIPPING"value="1"/>
<input type="hidden" name="VERSION" value="65.1">
</p>
</form>
I then do an ajax submit but I dont seem to get a returned token.
Any ideas, thanks in advanced!
SetExpressCheckout is only for getting a token. Once you get that token you redirect the user to PayPal with that token appended to the end of the URL. For digital goods, that would be something like this: https://www.sandbox.paypal.com/incontext?useraction=commit&token=EC-8MB725812K847260R
There the user signs in to PayPal to review and approve the payment and they are then sent back to the ReturnURL you specify in your SEC request.
At this point you can call GetExpressCheckoutDetails (optional) and you finalize everything by calling DoExpressCheckoutPayment. Only after the DECP call is made will any payment actually be processed.
For more details refer to the Express Checkout Integration Guide.

Categories

Resources