curl_post_form()
POST application/x-www-form-urlencoded data to a URL. Sets the method to POST and form-encodes data. A wrapper around curl_request().
Syntax
curl_post_form(url, data?, opts?)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url |
string | yes | The request URL. |
data |
array | no | The body — encoded as form fields. |
opts |
array | no | Extra options — see curl_request(). |
Returns
A response array (ok, status, headers, body, error).
Example
$resp = curl_post_form("https://example.com/subscribe", [
"email" => $record["email"],
"list" => "newsletter"
]);
if ( ! $resp["ok"] ) sys_log("Subscribe failed: " . $resp["error"]);
Example output
["ok" => true, "status" => 302, ...]
See also: curl_post_json(), curl_request()