screenshotmachine php
1.0.0
Webサイトのスクリーンショットをキャプチャし、スクリーンショットマシンを使用してWebサイトをPDFに変換します - オンラインWebサイトスクリーンショットジェネレーターとWebサイトをPDFコンバーターに。
a)Composerの使用 - PHPのパッケージマネージャー
php composer.phar require screenshotmachine/screenshotmachine-phpb)github.comから直接ソースコードをダウンロードしてください
まず、www.screenshotmachine.com Webサイトで無料/プレミアムアカウントを作成する必要があります。登録後、ユーザープロファイルに顧客キーが表示されます。また、ここでは秘密のフレーズが維持されています。 API呼び出しが公開されているWebサイトから呼び出される場合は、常に秘密のフレーズを使用してください。
スクリプトで顧客キーと秘密のフレーズ(必要に応じて)をセットアップします。
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed ニーズを満たすために追加のオプションを設定します。
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website screenshot API guide for more details
$ options [ ' dimension ' ] = " 1366x768 " ; // or "1366xfull" for full length screenshot
$ options [ ' device ' ] = " desktop " ;
$ options [ ' format ' ] = " png " ;
$ options [ ' cacheLimit ' ] = " 0 " ;
$ options [ ' delay ' ] = " 200 " ;
$ options [ ' zoom ' ] = " 100 " ;オプションの詳細については、当社のWebサイトスクリーンショットAPIをご覧ください。
<?php
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed
$ machine = new ScreenshotMachine ( $ customer_key , $ secret_phrase );
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website screenshot API guide for more details
$ options [ ' dimension ' ] = " 1366x768 " ; // or "1366xfull" for full length screenshot
$ options [ ' device ' ] = " desktop " ;
$ options [ ' format ' ] = " png " ;
$ options [ ' cacheLimit ' ] = " 0 " ;
$ options [ ' delay ' ] = " 200 " ;
$ options [ ' zoom ' ] = " 100 " ;
$ api_url = $ machine -> generate_screenshot_api_url ( $ options );
//put link to your html code
echo ' <img src=" ' . $ api_url . ' "> ' . PHP_EOL ;生成されたapi_urlリンクは、 <img>タグに配置するか、後でビジネスロジックで使用できます。
キャプチャされたスクリーンショットを画像として保存する必要がある場合は、次のように電話してください。
<?php
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed
$ machine = new ScreenshotMachine ( $ customer_key , $ secret_phrase );
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website screenshot API guide for more details
$ options [ ' dimension ' ] = " 1366x768 " ; // or "1366xfull" for full length screenshot
$ options [ ' device ' ] = " desktop " ;
$ options [ ' format ' ] = " png " ;
$ options [ ' cacheLimit ' ] = " 0 " ;
$ options [ ' delay ' ] = " 200 " ;
$ options [ ' zoom ' ] = " 100 " ;
$ api_url = $ machine -> generate_screenshot_api_url ( $ options );
//save screenshot as an image
$ output_file = ' output.png ' ;
file_put_contents ( $ output_file , file_get_contents ( $ api_url ));
echo ' Screenshot saved as ' . $ output_file . PHP_EOL ;キャプチャされたスクリーンショットは、現在のディレクトリのoutput.pngファイルとして保存されます。
PDFオプションを設定します。
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website to PDF API guide for more details
$ options [ ' paper ' ] = " letter " ;
$ options [ ' orientation ' ] = " portrait " ;
$ options [ ' media ' ] = " print " ;
$ options [ ' bg ' ] = " nobg " ;
$ options [ ' delay ' ] = " 2000 " ;
$ options [ ' scale ' ] = " 50 " ;オプションの詳細については、当社のWebサイトからPDF APIをご覧ください。
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed
$ machine = new ScreenshotMachine ( $ customer_key , $ secret_phrase );
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website to PDF API guide for more details
$ options [ ' paper ' ] = " letter " ;
$ options [ ' orientation ' ] = " portrait " ;
$ options [ ' media ' ] = " print " ;
$ options [ ' bg ' ] = " nobg " ;
$ options [ ' delay ' ] = " 2000 " ;
$ options [ ' scale ' ] = " 50 " ;
$ pdf_api_url = $ machine -> generate_pdf_api_url ( $ options );
//save PDF file
$ output_file = ' output.pdf ' ;
file_put_contents ( $ output_file , file_get_contents ( $ pdf_api_url ));
echo ' PDF saved as ' . $ output_file . PHP_EOL ;キャプチャされたPDFは、現在のディレクトリのoutput.pdfファイルとして保存されます。
MITライセンス(MIT)