For more information about the development of the new WeChat document (May 2016), please refer to the experts in the CSDN version.

Source: Internet
Author: User
Regarding the latest (2016) development of new documents, I beg the experts in the CSDN version to look at the development documents of the new version in 2016. the interfaces called are all under the https protocol, however, I encountered a problem in project development:
When uploading image materials on the server, data transmission over the https protocol cannot be implemented through CURL extension, resulting in media data being called through the interface.
Is missing. However, the official website does not provide a specific data type. I do not know whether the data format received by the server is different from the previous one.
Under that http protocol, CURL extension can easily return you a json data format and perform the next step through media_id. I have tried many methods
Fie_get_contents used to convert the file into a binary file and transmit it to the server. However, the json format is ineffective,


Please refer to the PHP version !!!


Reply to discussion (solution)

This is an interface I wrote last year to upload a material Library.

// Upload permanent material address const UPLOADIMAGE = "https://api.weixin.qq.com/cgi-bin/material/add_material? "; Function upload_curl_pic ($ file) {$ file = "@". dirname (DATA_DIR ). "/data/temp /". $ file; $ fields = array ("media" => $ file); $ media_id = $ this-> http_postform (self: UPLOADIMAGE. 'access _ token = '. $ this-> access_token, $ fields); return $ media_id;}/** form Upload permanent clip file * return media_id => clip id */public function http_postform ($ url, $ data = null) {$ curl = curl_init (); curl_setopt ($ curl, CURLOPT_URL, $ url); curl_setopt ($ curl, CUR LOPT_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);} curl_setopt ($ curl, expires, 1 ); $ output = curl_exec ($ curl); curl_close ($ curl); return $ output ;}


I just tried it. it's okay. actually, she asked you to use the form method of curl to upload information similar to the form file upload in html. you need to set information such as filename, filelength, and content-type.

I don't know how your program is written. I think the interface hasn't changed much. I have been using the write interface for two years. I haven't found any problem. which interface do you mean?

Currently, this method is not used to upload temporary and permanent materials for new materials. in this way, I have tried curl. in 2016, the new interface is different from the method used for calling https: I tried curl to be valid for http, but it was depressing for https.

Due to my environment problems, CURL extension cannot be used.

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.