<repo_name>purocean/php-api-service<file_sep>/captcha/index.php
<?php
/**
 * 若快验证码人工打码接口
 * post data=bas64.
 */

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://api.ruokuai.com/create.json');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 65);

curl_custom_postfields($ch, [
    // 'username' => '填写你的用户名',
    // 'password' => '<PASSWORD>',
    'typeid' => 3000, // 4位的字母数字混合码   类型表http://www.ruokuai.com/pricelist.aspx
    'timeout' => 60,  // 中文以及选择题类型需要设置更高的超时时间建议90以上
    'softid' => 53089,
    'softkey' => '1e3caa0b568b450ebd25e33526a7c294',
], [
    // 'image' => file_get_contents('img.jpg'),
    'image' => base64_decode($_POST['data']),
]);

$result = curl_exec($ch);
curl_close($ch);

die($result);


/**
 * For safe multipart POST request for PHP5.3 ~ PHP 5.4.
 *
 * @param resource $ch    cURL resource
 * @param array    $assoc "name => value"
 * @param array    $files "name => path"
 *
 * @return bool
 *
 * @link http://php.net/manual/en/class.curlfile.php
 */
function curl_custom_postfields(&$ch, array $assoc = array(), array $files = array())
{

    // invalid characters for "name" and "filename"
    static $disallow = array("\0", '"', "\r", "\n");

    // build normal parameters
    foreach ($assoc as $k => $v) {
        $k = str_replace($disallow, '_', $k);
        $body[] = implode("\r\n", array(
            "Content-Disposition: form-data; name=\"{$k}\"",
            '',
            filter_var($v),
        ));
    }

    // build file parameters
    foreach ($files as $k => $v) {
        $k = str_replace($disallow, '_', $k);
        $body[] = implode("\r\n", array(
            "Content-Disposition: form-data; name=\"{$k}\"; filename=\"{$k}\"",
            'Content-Type: application/octet-stream',
            '',
            $v,
        ));
    }

    // generate safe boundary
    do {
        $boundary = '---------------------'.md5(mt_rand().microtime());
    } while (preg_grep("/{$boundary}/", $body));

    // add boundary for each parameters
    array_walk($body, function (&$part) use ($boundary) {
        $part = "--{$boundary}\r\n{$part}";
    });

    // add final boundary
    $body[] = "--{$boundary}--";
    $body[] = '';

    // die(implode("\r\n", $body));

    // set options
    return curl_setopt_array($ch, array(
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => implode("\r\n", $body),
        CURLOPT_HTTPHEADER => array(
            'Expect: 100-continue',
            "Content-Type: multipart/form-data; boundary={$boundary}", // change Content-Type
        ),
    ));
}
<file_sep>/email/send2me.php
<?php

/**
 * 使用 SendCloud 向自己发送邮件
 *
 * @param string $subject 邮件主题
 * @param string $html    邮件正文
 *
 * @return string 发送结果
 */
function sendMail2Me($subject, $html)
{
    $url = 'http://sendcloud.sohu.com/webapi/mail.send.json';
    $apiUser = '';
    $apiKey = '';

    //不同于登录SendCloud站点的帐号，您需要登录后台创建发信子帐号，使用子帐号和密码才可以进行邮件的发送。
    $param = [
        'api_user' => $apiUser,
        'api_key' => $apiKey,
        'from' => '<EMAIL>',
        'fromname' => 'SendCloud测试邮件',
        'to' => '',
        'subject' => $subject,
        'html' => $html,
        'resp_email_id' => 'true'
    ];

    $data = http_build_query($param);

    $options = [
        'http' => [
            'method'  => 'POST',
            'header' => 'Content-Type: application/x-www-form-urlencoded',
            'content' => $data
        ]
    ];

    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);

    return $result;
}

echo sendMail2Me($_GET['subject'], $_GET['html']);
