D
D
Denis Bondarenko2017-01-10 22:58:54
PHP
Denis Bondarenko, 2017-01-10 22:58:54

How to login to videoigr.net using PHP/cURL?

Dear friends, please help.
I decided to write a script that parses the personal account page of the videoigr.net online store. And I came across an authorization problem, I tried to implement it using cURL. I tried to copy-paste examples from here xdan.ru/avtorizacija-na-sajte-pri-pomoshhi-curl-ph... , and, for example, from here https://htmlweb.ru/php/example/curl_login.php (the written code itself, Unfortunately, on a machine that I don't have access to yet).
In the process, question after question arises: how to save cookies correctly, whether it is necessary to access the page in two stages (authorization, and then parsing the personal account), etc. etc.
Plus, the page itself is full of stuffing.
Tried logging in with both videoigr.net andvideoigr.net/login.php Subsequently, it will be necessary to parse videoigr.net/account.php , but parsing is the tenth question, I at least have access to its contents under my credentials.
I would be grateful for the slightest help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2017-01-10
@Mad_Electron

1. Get the page with curl http://videoigr.net/login.php
2. Find the form with name="login" and grab the action value from there, for example

http://videoigr.net/login.php?action=process&osCsid=e1caaae9002758dc6bcbdc7179c14d82
- osCsid most likely plays a role (or maybe not. You need to experiment)
3. Send a post-request with the email_address and password fields to the address received from the action
. That's it.
Important points:
• Using CURLOPT_FOLLOWLOCATION equal to 1, after authorization you will be immediately redirected, most likely to your personal account. If not, make a new request to the correct address.
• curl will store the cookies itself
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); // сохранять куки в файл
curl_setopt($ch, CURLOPT_COOKIEFILE,  'cookie.txt'); // считываем куки

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question