我用原生PHP写得接口,在使用
dingtalk.corp.message.corpconversation.asyncsend (企业会话消息异步发送) 接口时,明明已经传输了method参数,但是接口还是返回
21Missing methodhttp传入的参数加入method字段ish43gzd66fs
这样的错误,请问是我传输方式不对还是怎么回事啊?
下面我把源码粘上:
<?php
$access_token=file_get_contents('https://oapi.dingtalk.com/gettoken?corpid=dingefd0c3b****3e9c135c2f4657eb6378f&corpsecret=fEi6l6HuEvfTRZuur6****4s2zVVSuvGk9pBhSc8P5Yuy0MIizL_Zv3EXpQ6jT3');
$obj=json_decode($access_token);
//$access_token=$obj->access_token;
define(ACCESS_TOKEN,$obj->access_token);
$link=array("messageUrl"=>"http://wx.apkipa.cn/app/./index.php?i=3&c=entry&eid=201","picUrl"=>"http://b.hiphotos.baidu.com/image/pic/item/aa64034f78f0f736ce4ff5720055b319ebc4130b.jpg","title"=>"点进去试试","text"=>"事实就是是");
$timestamp=date("Y-m-d H:i:s");
$post_data=array("method"=>"dingtalk.corp.message.corpconversation.asyncsend","session"=>ACCESS_TOKEN,"format"=>"json","v"=>"2.0","timestamp"=>$timestamp,"touser"=>"06592423208****6","agentid"=>"12***238","msgtype"=>"link","msgcontent"=>$link);
//$post_data="method=dingtalk.corp.message.corpconversation.asyncsend&session".ACCESS_TOKEN;
echo $json=json_encode($post_data);
$url="https://eco.taobao.com/router/rest";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json))
);
$result = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
echo $result;
?>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。