1 $url = 'http://www.sendcloud.net/webapi/template.update.json'; 2 3 $API_USER = ''; 4 $API_KEY = ''; 5 6 $content = "hello world";//需要替换的html内容 7 8 $param = array( 9 'api_user' => $API_USER, # 使用api_user和api_key进行验证 10 'api_key' => $API_KEY, 11 'invoke_name' => 'talk', 12 'html' => $content, 13 ); 14 15 16 $data = http_build_query($param); 17 18 $options = array( 19 'http' => array( 20 'method' => 'POST', 21 'header' => 'Content-Type: application/x-www-form-urlencoded', 22 'content' => $data 23 )); 24 $context = stream_context_create($options); 25 $result = file_get_contents($url, FILE_TEXT, $context); 26 echo $result;
之前使用curl方法一直报错,这个才是对的