|
HTML代码示例:- <form action="http://api.XXXXXX.cn/api/" method="post">
- key:<input type="text" name="key"><br>
- type:<input type="text" name="type"><br>
- o_id:<input type="text" name="o_id"><br>
- data:<input type="text" name="data"><br>
- <input type="submit">
- </form>
复制代码
PHP代码示例:数组方式和字符串拼接方式都可以- $url = "http://api.xxxxx.cn/api/";
- $post_data = ["key" => "xxxxx","o_id" => "1","type" => "suoyinchi","data" => "http://www.baidu.com/"];
- $header = ["User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"];
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
- $output = curl_exec($ch);
- curl_close($ch);
- print_r($output);
复制代码
|
|