Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to upload temporary material developed by php Wechat

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to upload temporary materials for php WeChat development. The introduction in the article is very detailed and has certain reference value. Interested friends must read it!

specific contents are 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-> curl_Get ($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); //execute curl, grab URL and pass it to browser $output = curl_exec($curl); //close cURL resource and free system resource curl_close($curl); return $output;}

Call uploadImg($imgurl) to pass image address parameters

return results

array ( 'type' => 'image','media_id' => ' W89mt3FEaxXOMOw0fLj2Cb6A8vfMjuXrj6XW59O3l9a7Tj_h3SjlBEr4dvp4Du2R','created_at' => 1464140301, Above is "php WeChat development how to achieve upload temporary materials" All the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report