0

I am designing a third party application that requires a POST request to be sent to a php file on a website and hopefully I should get a response. The site requires me to be logged in in order to make this request normally through the site by pressing a button on it. If I do

Url obj = new URL("http://www.dota2lounge.com/ajax/bumpTrade.php"; 
HttpUrlConnection con = (HttpUrlConnection) obj.openConnection();
con.setRequestProperty("User-Agent", "Chrome/36.0.1916.144");

And then continue to carry out the POST request, will the site recognize that I am sending this from my Chrome browser in which I am already logged in? Thanks

ok2c
  • 26,450
  • 5
  • 63
  • 71
lsnow2017
  • 139
  • 1
  • 2
  • 13

2 Answers2

0

will the site recognize that I am sending this from my Chrome browser in which I am already logged in?

No, it will not. Imagine how easy it would be to spoof the authentication system of a web application if it worked that way.

Logins typically work by sending Cookies or other headers. You need to send those to authenticate your request. For this to work as if you were logged in with your Chrome application, you'll need to find the corresponding cookies that Chrome stored and send those.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
0

You can find from the link i shared how you can make the authentication. https://stackoverflow.com/a/3283496/1257445

After you have made an authentication you can make a post request using the session

Community
  • 1
  • 1