PHP code example of zyan / url2pic-sdk

1. Go to this page and download the library: Download zyan/url2pic-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zyan / url2pic-sdk example snippets


use Zyan\UrlToPic\UrlToPic;

$key = '通信密钥';

$app = new UrlToPic($key);

$app->url2pic('http://www.baidu.com');

//code
//$app->url2pic(string $url, string $type = 'jpg', int $width = 1440, int $timeout = 30)

Array
(
    [code] => 1
    [msg] => ok
    [data] => Array
        (
            [download_link] => http://url2pic.php127.com/uploads/pic/2021-04-14/pic60765e8c046c4febb7b22335b326cd5bc40b8c80a5042_1440.jpg
        )

)

$urls = [
    'http://www.php127.com',
    'http://www.baidu.com'
];
$app->batch($urls);

//code
//$app->batch(array $urls, string $type = 'jpg', int $width = 1440);

Array
(
    [code] => 1
    [msg] => ok
    [data] => Array
        (
            [taskid] => task60765e924b755202104140316346
        )

)

$app->status('taskxxxxxx');

Array
(
    [code] => 1
    [msg] => ok
    [data] => Array
        (
            [count] => 2
            [status] => 1
            [list] => Array
                (
                    [0] => Array
                        (
                            [url] => http://www.php127.com/
                            [state] => 1
                            [download_link] => http://url2pic.php127.com/uploads/pic/2021-04-14/pic60765c9caa717a0ed430033638fefe3a07be15d6e9eac_1440.jpg
                        )

                    [1] => Array
                        (
                            [url] => http://www.baidu.com
                            [state] => 1
                            [download_link] => http://url2pic.php127.com/uploads/pic/2021-04-14/pic60765ca1bc6d7f9cd904c266e7f7ff4d63deb9ef6adce_1440.jpg
                        )

                )

        )

)