Exemplo n.º 1
0
function sendweixinmsg($touser, $content)
{
    //更换成自己的APPID和APPSECRET
    $APPID = "wx47180ba69fa68387";
    $APPSECRET = "QOqy71o3DC0IcC-l4MayHt13AFhABoPTIcKt23vbJydL2D-1nMyMcPQhF74XAS9VK3kh2NYIVNP1cxsPZ0K_HrNev41SRNjZ5Bq-TNwN9JM";
    $TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $APPID . "&secret=" . $APPSECRET;
    $json = file_get_contents($TOKEN_URL);
    $result = json_decode($json);
    $ACC_TOKEN = $result->access_token;
    $data = '{
        "touser":"******",
        "msgtype":"text",
        "text":
        {
             "content":"' . $content . '"
        }
    }';
    $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . $ACC_TOKEN;
    $result = https_post($url, $data);
    $final = json_decode($result);
    return $final;
}
Exemplo n.º 2
0
$jsoninfo = json_decode($result, true);
$ticket = $jsoninfo["ticket"];
echo "<p>scene_id : 3</p>";
$imgurl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . $ticket;
echo "<img src='" . $imgurl . "'>";
$qrcode = '{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": 4 }}}';
$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $access_token;
$result = https_post($url, $qrcode);
$jsoninfo = json_decode($result, true);
$ticket = $jsoninfo["ticket"];
echo "<p>scene_id : 4</p>";
$imgurl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . $ticket;
echo "<img src='" . $imgurl . "'>";
$qrcode = '{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": 5 }}}';
$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $access_token;
$result = https_post($url, $qrcode);
$jsoninfo = json_decode($result, true);
$ticket = $jsoninfo["ticket"];
echo "<p>scene_id : 5</p>";
$imgurl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . $ticket;
echo "<img src='" . $imgurl . "'>";
function https_post($url, $data = null)
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    if (!empty($data)) {
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
Exemplo n.º 3
0
function https_get($url, $timeout = 30, $cookie = '')
{
    return https_post($url, $timeout, '', $cookie);
}
            parse_str($token_response, $params);
            $app_access_token = $params['access_token'];
            $achievement = 'http://excellencetechnologies.co.in/fb/achievement.php?id=' . rand(0, 100);
            print 'Register a User Achievement<br/>';
            $achievement_display_order = 1;
            $achievement_registration_URL = 'https://graph.facebook.com/' . $app_id . '/achievements';
            $achievement_registration_result = https_post($achievement_registration_URL, 'achievement=' . $achievement . '&display_order=' . $achievement_display_order . '&access_token=' . $app_access_token);
            print 'Publish a User Achievement<br/>';
            $achievement_URL = 'https://graph.facebook.com/' . $user_profile['id'] . '/achievements';
            $achievement_result = https_post($achievement_URL, 'achievement=' . $achievement . '&access_token=' . $app_access_token);
            print '<br/><br/>';
            $score = 1;
            // POST a user score
            print 'Publish a User Score<br/>';
            $score_URL = 'https://graph.facebook.com/' . $user_profile['id'] . '/scores';
            $score_result = https_post($score_URL, 'score=' . $score . '&access_token=' . $app_access_token);
            print '<br/><br/>';
        } catch (Exception $e) {
            echo $e->getMessage() . '<br>';
        }
        print_r($user_profile);
        print_r($params);
    } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}
function https_post($uri, $postdata)
{
    $ch = curl_init($uri);
    curl_setopt($ch, CURLOPT_POST, true);