-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加 cli 下输入验证码示例代码
- Loading branch information
Showing
5 changed files
with
192 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* 在 CLI 下当出现验证码时,要求用户输入验证码 | ||
*/ | ||
|
||
require '../vendor/autoload.php'; | ||
|
||
$client = new Consatan\Weibo\ImageUploader\Client(); | ||
$username = 'weibo_username'; | ||
$password = 'password'; | ||
|
||
while (true) { | ||
try { | ||
echo $client->upload('./example.png', $username, $password); | ||
break; | ||
} catch (Consatan\Weibo\ImageUploader\Exception\RequirePinException $e) { | ||
echo '验证码图片位置:' . $e->getMessage() . PHP_EOL . '输入验证码以继续:'; | ||
if (!$client->login($username, $password, stream_get_line(STDIN, 1024, PHP_EOL))) { | ||
echo '登入失败'; | ||
break; | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Consatan\Weibo\ImageUploader package. | ||
* | ||
* (c) Chopin Ngo <consatan@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Consatan\Weibo\ImageUploader\Exception; | ||
|
||
class RequirePinException extends RuntimeException | ||
{ | ||
} |