HTML,使用给定的curl请求创建表单帖子

时间:2017-01-07 19:43:27

标签: php html curl

我创建了一个像这样的html表单

<h1><a>Create Event</a></h1>
        <form id="form_4068" class="appnitro"  method="post" action="https://siteName/applications/**{application_id}**/deployments.json">
                    <div class="form_description">
            <h2>Create Event</h2>
        </div>                      
            <ul >

            <li id="li_2" >
        <label class="description" for="element_2">Title </label>
        <div>
            <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value=""/> 
        </div> 
        </li>       <li id="li_5" >
        <label class="description" for="element_5">User </label>
        <div>
        <select class="element select medium" id="element_5" name="element_5"> 
            <option value="" selected="selected"></option>
                    <option value="1" >user1</option>
                    <option value="2" >user2</option>
                    <option value="3" >user3</option>
        </select>
        </div> 
        </li>       <li id="li_1" >
        <label class="description" for="element_1">Application </label>
        <div>
        <select class="element select medium" id="element_1" name="element_1"> 
            <option value="" selected="selected"></option>
<option value="1" >App1</option>
<option value="2" >App2</option>
<option value="3" >App3</option>

        </select>
        </div> 
        </li>       <li id="li_3" >
        <label class="description" for="element_3">Change Log </label>
        <div>
            <textarea id="element_3" name="element_3" class="element textarea small"></textarea> 
        </div> 
        </li>       <li id="li_4" >
        <label class="description" for="element_4">Description </label>
        <div>
            <textarea id="element_4" name="element_4" class="element textarea small"></textarea> 
        </div> 
        </li>

                    <li class="buttons">
                <input type="hidden" name="form_id" value="4068" />

                <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
        </li>
            </ul>
        </form> 

我收到了以下CURL REQUEST

curl -X POST 'https://siteName.com/v2/applications/{application_id}/deployments.json' \
     -H 'X-Api-Key:123456789' -i \
     -H 'Content-Type: application/json' \
     -d \
'{
  "deployment": {
    "Title": "string",
    "changelog": "string",
    "description": "string",
    "user": "string"
  }
}' 

这是包含curl命令的php

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://theSite.com/v2/applications/{application_id}/deployments.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "\n'{");
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "X-Api-Key: 123456789";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>

我想提供html页面,以便任何人都可以在curl请求中使用我的API创建活动。

我的问题是: 在创建表单html页面之后,如何在表单中发布所有给定内容并匹配请求的卷曲的URL?

感谢

0 个答案:

没有答案