PHP micro-development of the upload temporary material, PHP development Material _php Tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.