M
M
maloy-kachok2015-12-08 17:46:10
PHP
maloy-kachok, 2015-12-08 17:46:10

How to send files for uniqueness check to antiplagiat.ru/ via curl?

Hello. The question arose of how to send a file from your server for verification to the antiplagiat.ru service through a curl or a socket, I did authorization through a curl. but how to make it so that later it was possible to send a file from this session, I can’t figure it out. Below is the code - maybe it will be useful to someone, if you find a solution to my problem, please tell me. Thank you.

<?php
  $curl = curl_init();
  //Устанавливаем значение referer - адрес последней активной страницы
  curl_setopt($curl, CURLOPT_REFERER, 'http://www.antiplagiat.ru/');
    curl_setopt($curl, CURLOPT_COOKIESESSION, true); 
    curl_setopt($curl, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'/curl/cookie.txt'); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
  curl_setopt($curl, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/curl/cookie.txt');
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3'); 
    curl_setopt($curl, CURLOPT_URL, 'http://www.antiplagiat.ru/'); 
    $html = curl_exec($curl);
    preg_match('/<input name="__RequestVerificationToken" type="hidden" value="(.*)"/Uis',$html, $login_csrf);

    $login_csrf = $login_csrf[1];

    //echo $login_csrf;

    $post = "Email=$Email&Password=$Password&RememberMe=true&__RequestVerificationToken=".$login_csrf;

    curl_setopt($curl, CURLOPT_URL, 'http://www.antiplagiat.ru/Account/Login');
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post);

    $html = curl_exec($curl);
   echo $html;
?php>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Matrozov, 2015-12-08
@Mear

Since you set cookies yourself when requesting, then after registering, you need to rip out the session cookies that probably appeared there from the response and pass them in the second request. Well, either don't mess around with cookies yourself (that is, don't set them), but simply call the second one after the first request (without doing curl_close). Curl itself passes cookies between requests and, in theory, authorization should be preserved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question