public function upImg()json
{api
$token = $this->getToken();curl
$data = array("img" => "@" . $this->imgUrl);ide
$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" . $token . "&type=p_w_picpath";this
$res = json_decode($this->curl($data,$url),true);url
$this->imgMedia = $res['media_id'];code
}token
public function curl($data,$url)get
{it
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
return curl_exec($ch);
curl_close($ch);
}