Beispiel #1
0
function _xml_to_array($xml)
{
    $reg = "/<(\\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
    if (preg_match_all($reg, $xml, $matches)) {
        $count = count($matches[0]);
        for ($i = 0; $i < $count; $i++) {
            $subxml = $matches[2][$i];
            $key = $matches[1][$i];
            if (preg_match($reg, $subxml)) {
                $arr[$key] = _xml_to_array($subxml);
            } else {
                $arr[$key] = $subxml;
            }
        }
    }
    return $arr;
}
Beispiel #2
0
 private function cfg_send_3($post_data = null, $target = null, $get_key = null)
 {
     //cf_tlwl
     //BPPKNes
     $config = $this->config;
     $account = $this->mobile['cfg_mobile_3']['mid'];
     $password = $this->mobile['cfg_mobile_3']['mpass'];
     //"您的验证码是:9707。请不要把验证码泄露给其他人。"
     $config['content'] = rawurlencode($config['content']);
     /*发送短信*/
     if (!$get_key) {
         $post_data = "account={$account}&password={$password}&mobile=" . $config['mobile'] . "&content=" . $config['content'];
         $target = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
     }
     /*curl*/
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $target);
     curl_setopt($curl, CURLOPT_HEADER, false);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_NOBODY, true);
     curl_setopt($curl, CURLOPT_POST, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
     $return_str = curl_exec($curl);
     curl_close($curl);
     /*curl*/
     /*xml*/
     $arr = _xml_to_array($return_str);
     /*xml*/
     if ($get_key) {
         $this->error = $arr['GetNumResult']['code'];
         $this->v = $arr['GetNumResult']['num'];
         return $arr;
     }
     /*成功*/
     if ($arr['SubmitResult']['code'] == 2) {
         $this->v = $arr['SubmitResult']['msg'];
         $this->error = 1;
     } else {
         $this->v = $arr['SubmitResult']['msg'];
         $this->error = -1;
     }
     return $arr;
 }