Skip to content

Instantly share code, notes, and snippets.

@Sharifur
Created June 2, 2020 16:29
Show Gist options
  • Save Sharifur/3dcd7293de2322693b9e5643347ec3ac to your computer and use it in GitHub Desktop.
Save Sharifur/3dcd7293de2322693b9e5643347ec3ac to your computer and use it in GitHub Desktop.
wp_remote_post.php () example
$endpoint = 'api.example.com';
$body = [
'name' => 'Pixelbart',
'email' => 'pixelbart@example.com',
];
$body = wp_json_encode( $body );
$options = [
'body' => $body,
'headers' => [
'Content-Type' => 'application/json',
],
'timeout' => 60,
'redirection' => 5,
'blocking' => true,
'httpversion' => '1.0',
'sslverify' => false,
'data_format' => 'body',
];
wp_remote_post( $endpoint, $options );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment