예제 #1
0
 public function zfunc($zimgname, $zimgurl)
 {
     $wx = new weixin();
     $access_token = $wx->get_tk();
     //下载图片,转发上传到微信临时素材库
     $imageData = $wx->httpGet($zimgurl);
     $fp = fopen(dirname(__FILE__) . "/" . $zimgname . ".jpg", 'w+');
     fwrite($fp, $imageData);
     fclose($fp);
     $filepath = dirname(__FILE__) . "/" . $zimgname . ".jpg";
     $filedata = array("media" => "@" . $filepath);
     //Linux绝对路径
     $url = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token={$access_token}&type=image";
     $res = $wx->httpPost($url, $filedata);
     $res = json_decode($res);
     $media_id = $res->media_id;
     $wx->send_img(array('userid' => 'plustree', 'appid' => '2', 'mediaid' => $media_id));
     $b = "return seccess";
     return $b;
 }
예제 #2
0
파일: index2.php 프로젝트: wuya1986/php
             $wx->send_msg(array('userid' => (string) $fromUserName, 'appid' => (string) $agentID, 'msg' => '上传成功!'));
         }
         if ($soap_res_status == 'E') {
             $wx->send_msg(array('userid' => (string) $fromUserName, 'appid' => (string) $agentID, 'msg' => '上传失败!'));
         }
         $wx->log($content . "|||" . $picUrl);
         $redis->delete("content");
     }
 }
 //"#2 开启查询模式"的逻辑
 if ($msgType == "text" && $redis->get('type') == (string) $fromUserName . '2') {
     if ($content == '2') {
         $wx->send_msg(array('userid' => (string) $fromUserName, 'appid' => (string) $agentID, 'msg' => '请您输入要查询的图片名称'));
     }
     if ($content != '2') {
         $access_token = $wx->get_tk();
         //下载图片,转发上传到微信临时素材库
         $zimgurl = "http://192.168.5.134:7777/static/DEV/" . $content . ".jpg";
         $imageData = $wx->httpGet($zimgurl);
         if (stripos($imageData, "Not Found") == FALSE) {
             $fp = fopen(dirname(__FILE__) . "/" . $content . ".jpg", 'w+');
             fwrite($fp, $imageData);
             fclose($fp);
             $filepath = dirname(__FILE__) . "/" . $content . ".jpg";
             $filedata = array("media" => "@" . $filepath);
             //Linux绝对路径
             $url = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token={$access_token}&type=image";
             $res = $wx->httpPost($url, $filedata);
             $res = json_decode($res);
             $media_id = $res->media_id;
             $wx->send_img(array('userid' => (string) $fromUserName, 'appid' => (string) $agentID, 'mediaid' => (string) $media_id));
예제 #3
0
파일: oauth2.php 프로젝트: wuya1986/php
    $sql = "select language from customer_tbl where user_id = '" . $_SESSION['user_id'] . "'";
    $result = mysql_query($sql, $con);
    $row = mysql_fetch_array($result);
    if (empty($row)) {
        $_SESSION['language'] = "Language_EN";
    } else {
        $_SESSION['language'] = $row['language'];
    }
}
mysql_close($con);
$code = $_GET['code'];
if (!isset($_SESSION['access_token']) || !isset($_SESSION['token_time']) || !isset($_SESSION['user_id']) || !isset($_SESSION['device_id']) || !isset($_SESSION['language'])) {
    $sid = session_id();
    $obj = new weixin();
    $tk = "";
    $tk = $obj->get_tk();
    $agentid = "1";
    $get_url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={$tk}&code={$code}&agentid={$agentid}";
    $ch = curl_init($get_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    $result = json_decode($result);
    $result = (array) $result;
    $_SESSION['access_token'] = $tk;
    $_SESSION['token_time'] = time();
    $_SESSION['user_id'] = $result["UserId"];
    $_SESSION['device_id'] = $result["DeviceId"];
    $_SESSION['language'] = "Language_EN";
    //database
    $con = mysql_connect("127.0.0.1", "root", "root");
    mysql_select_db("wx", $con);