私はPhantomJSとPHP-PhantomJSを学んでいます。私はPhantomJSにスクリプトを渡したいと思います。私は$client->send($request, $response)
を呼び出した後、バックに空$response
オブジェクトを取得していますPHP-PhantomJS経由でPhantomJSにスクリプトを渡す正しい方法は?
$client->getEngine()->addOption('/Applications/myWebApp/js/phantomtest.js');
$request = $client->getMessageFactory()->createRequest('http://www.jonnyw.me/', 'GET');
$response = $client->getMessageFactory()->createResponse();
$client->send($request, $response);
if ($response->getStatus() === 200) {
echo $response->getContent();
}
:
現在、私はこれをしようとしています。
Here's the contents of my test script ('phantomtest.js'):
var page = require('webpage').create();
page.open('http://www.jonnyw.me', function(status) {
console.log("Status: " + status);
if(status === "success") {
page.render('example.png');
}
phantom.exit();
});
興味深いですが、ちょうどバックティックを使用します。 – pguardiario
@pguardiario、これに対してバックティックを使用する正しい方法は何ですか? – VikR
'<?php \'/usr/bin/phantomjs /path/to/script.js\ '?>'または[exec](http://php.net/manual/en/function.exec.php) – Vaviloff