A
A
Alexander2018-12-10 13:00:10
PHP
Alexander, 2018-12-10 13:00:10

Why is curl_exec not outputting data?

header('Content-type: text/html; charset=utf-8');
require 'phpQuery/phpQuery.php';

function debug($arr) {
    echo '<pre>'. print_r($arr, true). '</pre>';
}
function getContent($url, $data = []) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_COOKIEJAR, __DIR__ . '/cookie.txt');
    curl_setopt($ch, CURLOPT_COOKIEFILE, __DIR__ . '/cookie.txt');
    $res = curl_exec($ch);
    curl_close($ch);
    return $res;
}

$urlAuth = 'https://auth.mail.ru/cgi-bin/auth';
$url = 'https://wf.mail.ru/officers';
$auth_data = [
    'Page'          => 'https://wf.mail.ru/',
    'FakeAuthPage'  => 'https://wf.mail.ru/auth',
    'Login'         => 'МоеМыло',
    'Password'      => 'мойПароль',
    'do_login'      => ''
];

$data = getContent($urlAuth, $auth_data);
$data = getContent($url);
debug($data);

The data is written to the cookie file perfectly, but when I go to the wf.mail.ru/officers page, the content is not displayed.
Please tell me what is wrong. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-12-11
@vaajnur

are you fooling people? the fact that the link https://wf.mail.ru/officers/ is available from the browser does not mean that it works via api. See here how to work with api
https://wf.mail.ru/wiki/index.php/API#.D0.9E.D0.BF...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question