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.