<?php
function request_get($url)
{
$ch = curl_init();
$opts = array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_TIMEOUT => 30,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
);
curl_setopt_array($ch, $opts);
$output = curl_exec($ch);
if (curl_errno($ch)) {
var_dump(curl_error($ch));
die;
}
curl_close($ch);
return $output;
}
function post( $url, $data ) {
$data = json_encode($data);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 10 );
$output = curl_exec( $ch );
curl_close( $ch );
return $output;
}
$post = array(
'type' => 'itemDel',
'data'=>array('_id'=>$_POST['id'])
);
$posturl = "https://api.weixin.qq.com/XXX";
$a = post($posturl, $post);
$rs = json_decode(json_decode($a)->resp_data)->success;
|