代码如下
$upload = $this->dingtalkcurl('https://oapi.dingtalk.com/media/upload?access_token='.$token['access_token'].'&type=image', array('media'=>'@/static/admin/img/microcrm.png'));
$upload = $this->dingtalkcurl('https://oapi.dingtalk.com/media/upload?access_token='.$token['access_token'].'&type=image', array('media'=>'@./microcrm.png'));
function http_post($url,$param){
$oCurl = curl_init();
//下面判断https 和 http;因为钉钉接口是 Https请求
if(stripos($url,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($oCurl, CURLOPT_POST,true);
curl_setopt($oCurl, CURLOPT_POSTFIELDS,$param);
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}
public function dingtalkcurl($url,$data=null){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl,CURLOPT_POSTFIELDS,$data);
$output = curl_exec($curl);
$data = curl_getinfo($curl);
curl_close($curl);
return $output;
}
请忽略类不全之类的错误,直接看方法,图片绝对路径能够访问到,相对路径也能访问到。两种curl方式也尝试过,都报40035的错。
-------------------------
-------------------------
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。