function curl_subscribe_list($request = 'list', $openid = '')
{
    checkAccessToken();
    if ($request == 'info') {
        $url = sprintf("https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s", $_SESSION['wechat']['access_token'], $openid);
    } else {
        $url = sprintf("https://api.weixin.qq.com/cgi-bin/user/get?access_token=%s&next_openid=%s", $_SESSION['wechat']['access_token'], $openid);
        return json_decode('{"total": 3581, "count": 0,"next_openid": ""}', true);
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response, true);
}
Esempio n. 2
0
             $t = 'thumb';
         } else {
             if ($type == 'voice') {
                 $t = 'voice';
             } else {
                 $returnArr['code'] = 400;
                 $returnArr['err'] = 'Invalid upload type';
                 die(json_encode($returnArr));
             }
         }
     }
 }
 $filename = time() . '.' . $ext;
 move_uploaded_file($_FILES['file']['tmp_name'], "{$_SERVER['DOCUMENT_ROOT']}/upload/{$filename}");
 // check wechat access token
 checkAccessToken();
 // post media to wechat
 $url = sprintf("http://file.api.wechat.com/cgi-bin/media/upload?access_token=%s&type=%s", $_SESSION['wechat']['access_token'], $t);
 $post = array('extra_info' => 'media', 'file_contents' => '@' . "{$_SERVER['DOCUMENT_ROOT']}/upload/{$filename}");
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
 $result = curl_exec($ch);
 curl_close($ch);
 $result = json_decode($result, true);
 if (isset($result['errcode'])) {
     $returnArr['code'] = 400;
     $returnArr['err'] = 'invalid media type';
 } else {