PHP Developer upload Temporary material, PHP development material
This example for everyone to share the PHP upload temporary material specific code for your reference, the specific content as follows
Public Function uploadimg ($IMGURL) {$TOKEN = $this->getaccesstoken (); $URL = ' http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token= '. $TOKEN. ' &type=image '; $data = Array (' media ' = ' @ '. $imgUrl); $result = $this->curl_post ($URL, $data); $data = @json_decode ($result, true); return $data [' media_id ']; } public Function Getaccesstoken () {$url = ' https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential &appid=wxe574b1bd35d7d4da&secret=d4624c36b6795d1d99dcf0547af5443d '; $result = Json_decode ($this->curlget ($url), true); return $result [' Access_token ']; } function Curl_post ($url, $data = null) {//Create a new curl resource $curl = Curl_init ();//Set URL and corresponding options curl_setopt ($curl, Curlopt_url , $url); if (!empty ($data)) {curl_setopt ($curl, Curlopt_post, 1); curl_setopt ($curl, Curlopt_postfields, $data); } curl_setopt ($curl, Curlopt_returntransfer, 1); Executes curl, crawls the URL and passes it to the browser $output = curl_exec ($curl); Close the Curl resource and release the system Resource Curl_close ($curl); return $output;}
Call uploadimg ($imgurl) to pass the picture address parameter
return results
Array (' type ' = ' = ' image ', ' media_id ' = ' w89mt3feaxxomow0flj2cb6a8vfmjuxrj6xw59o3l9a7tj_h2sjlber4dvp4du2r ', ' Created_at ' = 1464140301,
The above is the whole content of this article, I hope that everyone's learning to help, but also hope that we support a lot of help the home.
http://www.bkjia.com/PHPjc/1138988.html www.bkjia.com true http://www.bkjia.com/PHPjc/1138988.html techarticle PHP Development of temporary material upload, PHP development material examples for everyone to share the PHP upload temporary material of the specific code for your reference, the specific content as follows public functi ...