環境
MAMP
PHP Version 7.1.1
Google Chrome
やりたい事
PHP PhantomJSを使って特定のURLのキャプチャを撮りたいです。
やるのは初めてではなく、PHP PhantomJSも下記の手順でインストール済みです。
composer.json
json
1 2{ 3 "require": { 4 "jonnyw/php-phantomjs": "4.*" 5 }, 6 "scripts": { 7 "post-install-cmd": [ 8 "PhantomInstaller\Installer::installPhantomJS" 9 ], 10 "post-update-cmd": [ 11 "PhantomInstaller\Installer::installPhantomJS" 12 ] 13 } 14}
$ composer install
vendor
ディレクトリもその中のautoload.php
、bin
の中のphantomjs
も存在を確認済みです。
その上で、
以下のコードが動きません。
PHP
1<?php 2 3require( 'vendor/autoload.php' ); 4 5use JonnyW\PhantomJs\Client; 6 7$client = Client::getInstance(); 8 9$request = $client->getMessageFactory()->createCaptureRequest('http://jonnyw.me'); 10$response = $client->getMessageFactory()->createResponse(); 11 12// ファイルの保存先を指定する 13$file = 'capture.jpg'; 14 15$request->setOutputFile($file); 16$client->send($request, $response);
デベロッパーツールで見ると、Status が 500 で返って来ています。どこがおかしいのかと色々コメントアウトしてみたら、最終行をコメントアウトした時だけ 200 になります。当然ですがキャプチャは撮れません。
エラーが吐き出されるのならまだしも、500 って構文エラーとかですよね?何が起こってるのか分からなくて。
一応MAMPを再起動もしてみたんですが、変わりませんでした。
打開策を教えていただけませんでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/19 21:42