X
X
Xveeder2019-08-17 17:02:37
JavaScript
Xveeder, 2019-08-17 17:02:37

How to return object value from JS to PHP via exec + phantom.js?

Good day, colleagues.
The essence of the question is as follows, let's say there is a js file:

var webPage = require('webpage');
var page = webPage.create();

page.open('https://vk.com/', function (status) {
    var cookies = page.cookies;
    phantom.exit();
});

This code is sent to phantom.js for execution via php:
$command =  'js\phantomjs.exe ' . 'src.js';
exec($command, $output);

var_dump(($output));

Question. What is the most correct way to pass the cookie object in PHP to the output variable?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question