Example #1
0
 function send($phones, $msg, $send_date = '', $send_num = 1, $sms_type = '', $version = '1.0', &$sms_error = '')
 {
     //function send($phones, $msg, &$sms_error = '') {
     /* 检查发送信息的合法性 */
     $contents = $this->get_contents($phones, $msg);
     if (!$contents) {
         return false;
     }
     /* 获取API URL */
     $sms_url = "http://106.ihuyi.com/webservice/sms.php?method=Submit";
     if (count($contents) > 1) {
         foreach ($contents as $key => $val) {
             $post_data = "account=" . $this->sms_name . "&password="******"&mobile=" . $val['phones'] . "&content=" . rawurlencode($val['content']);
             //密码可以使用明文密码或使用32位MD5加密
             //$get = $this->Post($post_data, $sms_url);
             $get = Http::doPost($sms_url, $post_data);
             $gets = $this->xml_to_array($get);
             sleep(1);
         }
     } else {
         $post_data = "account=" . $this->sms_name . "&password="******"&mobile=" . $contents[0]['phones'] . "&content=" . rawurlencode($contents[0]['content']);
         //密码可以使用明文密码或使用32位MD5加密
         //$get = $this->Post($post_data, $sms_url);
         $get = Http::doPost($sms_url, $post_data);
         $gets = $this->xml_to_array($get);
     }
     //print_r($gets);exit; //开启调试模式
     if ($gets['SubmitResult']['code'] == 2) {
         return true;
     } else {
         $sms_error = $gets['SubmitResult']['msg'];
         $this->logResult($sms_error);
         return false;
     }
 }
Example #2
0
 /**
  * 生成支付代码
  *
  * @param array $order 订单信息
  * @param array $payment 支付方式信息
  */
 function get_code($order, $payment)
 {
     $init_url = 'https://wap.tenpay.com/cgi-bin/wappayv2.0/wappay_init.cgi';
     $gateway = 'https://wap.tenpay.com/cgi-bin/wappayv2.0/wappay_gate.cgi';
     // 初始化
     $data = array('ver' => '2.0', 'charset' => 1, 'bank_type' => 0, 'desc' => $order['order_sn'], 'bargainor_id' => $payment['bargainor_id'], 'sp_billno' => $order['order_sn'] . 'O' . $order['log_id'], 'total_fee' => $order['order_amount'] * 100, 'fee_type' => 1, 'notify_url' => return_url(basename(__FILE__, '.php'), array('type' => 0)), 'callback_url' => return_url(basename(__FILE__, '.php'), array('type' => 1)));
     // 字典排序
     ksort($data);
     reset($data);
     // 生成签名
     $sign = '';
     foreach ($data as $key => $vo) {
         if ($vo !== '') {
             $sign .= $key . '=' . $vo . '&';
         }
     }
     $sign .= 'key=' . $payment['tenpay_key'];
     $data['sign'] = strtoupper(md5($sign));
     // 交易初始化
     $result = Http::doPost($init_url, $data);
     $xml = (array) simplexml_load_string($result);
     if (isset($xml['err_info'])) {
         return '<div style="color:red; text-align: center">错误信息:' . $xml['err_info'] . '</div>';
     }
     /* 生成支付按钮 */
     $button = '<div><input type="button" class="btn btn-info ect-btn-info ect-colorf ect-bg" onclick="window.open(\'' . $gateway . '?token_id=' . $xml['token_id'] . '\')" value="' . L('pay_button') . '" class="c-btn3" /></div>';
     return $button;
 }
Example #3
0
 public static function doRequest($url, $param)
 {
     $returnVal = Http::doPost($url, $param);
     if ($returnVal) {
         return json_decode($returnVal);
     } else {
         return false;
     }
 }
Example #4
0
 /**
  * 生成支付代码
  *
  * @param array $order
  *            订单信息
  * @param array $payment
  *            支付方式信息
  */
 function get_code($order, $payment)
 {
     if (!defined('EC_CHARSET')) {
         $charset = 'utf-8';
     } else {
         $charset = EC_CHARSET;
     }
     $gateway = 'http://wappaygw.alipay.com/service/rest.htm?';
     // 请求业务数据
     $req_data = '<direct_trade_create_req>' . '<subject>' . $order['order_sn'] . '</subject>' . '<out_trade_no>' . $order['order_sn'] . 'O' . $order['log_id'] . '</out_trade_no>' . '<total_fee>' . $order['order_amount'] . '</total_fee>' . '<seller_account_name>' . $payment['alipay_account'] . '</seller_account_name>' . '<call_back_url>' . return_url(basename(__FILE__, '.php'), array('type' => 0)) . '</call_back_url>' . '<notify_url>' . return_url(basename(__FILE__, '.php'), array('type' => 1)) . '</notify_url>' . '<out_user>' . $order['consignee'] . '</out_user>' . '<merchant_url>' . __URL__ . '</merchant_url>' . '<pay_expire>3600</pay_expire>' . '</direct_trade_create_req>';
     $parameter = array('service' => 'alipay.wap.trade.create.direct', 'format' => 'xml', 'v' => '2.0', 'partner' => $payment['alipay_partner'], 'req_id' => $order['order_sn'] . $order['log_id'], 'sec_id' => 'MD5', 'req_data' => $req_data, "_input_charset" => $charset);
     ksort($parameter);
     reset($parameter);
     $param = '';
     $sign = '';
     foreach ($parameter as $key => $val) {
         $param .= "{$key}=" . urlencode($val) . "&";
         $sign .= "{$key}={$val}&";
     }
     $param = substr($param, 0, -1);
     $sign = substr($sign, 0, -1) . $payment['alipay_key'];
     // 请求授权接口
     $result = Http::doPost($gateway, $param . '&sign=' . md5($sign));
     $result = urldecode($result);
     // URL转码
     $result_array = explode('&', $result);
     // 根据 & 符号拆分
     // 重构数组
     $new_result_array = $temp_item = array();
     if (is_array($result_array)) {
         foreach ($result_array as $vo) {
             $temp_item = explode('=', $vo, 2);
             // 根据 & 符号拆分
             $new_result_array[$temp_item[0]] = $temp_item[1];
         }
     }
     $xml = simplexml_load_string($new_result_array['res_data']);
     $request_token = (array) $xml->request_token;
     // 请求交易接口
     $parameter = array('service' => 'alipay.wap.auth.authAndExecute', 'format' => 'xml', 'v' => $new_result_array['v'], 'partner' => $new_result_array['partner'], 'sec_id' => $new_result_array['sec_id'], 'req_data' => '<auth_and_execute_req><request_token>' . $request_token[0] . '</request_token></auth_and_execute_req>', 'request_token' => $request_token[0], '_input_charset' => $charset);
     ksort($parameter);
     reset($parameter);
     $param = '';
     $sign = '';
     foreach ($parameter as $key => $val) {
         $param .= "{$key}=" . urlencode($val) . "&";
         $sign .= "{$key}={$val}&";
     }
     $param = substr($param, 0, -1);
     $sign = substr($sign, 0, -1) . $payment['alipay_key'];
     /* 生成支付按钮 */
     //$button = '<script type="text/javascript" src="'.__PUBLIC__.'/js/ap.js"></script><div><input type="button" class="btn btn-info ect-btn-info ect-colorf ect-bg l-pay-btn" onclick="javascript:_AP.pay(\'' . $gateway . $param . '&sign=' . md5($sign) . '\')" value="' . L('pay_button') . '" class="c-btn3" /></div>';
     $button = '<script type="text/javascript" src="' . __PUBLIC__ . '/js/ap.js"></script><input type="button" class="btn btn-info ect-btn-info ect-colorf ect-bg l-pay-btn" onclick="javascript:_AP.pay(\'' . $gateway . $param . '&sign=' . md5($sign) . '\')" value="' . L('pay_button') . '" class="c-btn3" />';
     return $button;
 }
Example #5
0
 public function test002()
 {
     $param = array("order_no" => "11111", "id" => "22222");
     $returnVal = Http::doPost("http://192.168.1.28:8088/quanpinMIS/doA0211.iss", $param);
     $returnObj = json_decode($returnVal);
     if ($returnObj->returnVal == "OK") {
         // OK
     } else {
         // NG
     }
 }
Example #6
0
 /**
  * 请求
  * @param type $data
  * @return type
  */
 private function run($data)
 {
     $fields = array('data' => json_encode($data), 'version' => VERSION, 'release' => RELEASE, 'act' => $this->act, 'identity' => $data['appid'], 'token' => $this->token);
     //请求
     $status = Http::doPost(self::serverHot, $fields);
     if (false == $status) {
         $this->error = '无法联系服务器,请稍后再试!';
         return false;
     }
     return $this->returnResolve($status);
 }
    $token = json_decode($data_token);
    //发货通知微信
    $url1 = 'https://api.weixin.qq.com/pay/delivernotify?access_token=' . $token->access_token;
    $data1 = Http::doPost($url1, $data, 5, '', 'json');
    $rs1 = json_decode($data1);
    //成功通知微信
    if ($rs1->errcode == 0) {
        //echo 'success';
    } else {
        //获取access_token
        $url_token1 = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $payment['wxpay_appid'] . '&secret=' . $payment['wxpay_appsecret'];
        $data_token1 = Http::doGet($url_token1);
        $token1 = json_decode($data_token1);
        //第一次失败再次发送发货通知微信
        $url2 = 'https://api.weixin.qq.com/pay/delivernotify?access_token=' . $token1->access_token;
        $data2 = Http::doPost($url2, $data, 5, '', 'json');
        $rs2 = json_decode($data2);
        if ($rs2->errcode == 0) {
            //echo 'success';
        } else {
            exit($rs2->errcode . ':' . $rs2->errmsg);
        }
    }
}
//打印日志
function logResult($word = '')
{
    $fp = fopen("log.txt", "a");
    flock($fp, LOCK_EX);
    fwrite($fp, "执行日期:" . strftime("%Y%m%d%H%M%S", time()) . "\n" . $word . "\n");
    flock($fp, LOCK_UN);