本文整理匯總了PHP中SendGrid::postRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP SendGrid::postRequest方法的具體用法?PHP SendGrid::postRequest怎麽用?PHP SendGrid::postRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SendGrid
的用法示例。
在下文中一共展示了SendGrid::postRequest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
/**
* Override Email send
*
* @param SendGrid\Email $email Email object with email info
* @param SendGrid $sendgrid Sendgrid object with credentials info
* @return array Array of results
*/
function wp_send(SendGrid\Email $email, $sendgrid)
{
$form = $email->toWebFormat();
$form['api_user'] = Sendgrid_Tools::get_username();
$form['api_key'] = Sendgrid_Tools::get_password();
$url = $sendgrid->url . $sendgrid->endpoint;
$files = preg_grep('/files/', array_keys($form));
if (count($files) > 0) {
if (in_array('curl', get_loaded_extensions())) {
$response = $sendgrid->postRequest($sendgrid->endpoint, $form);
$response = array('body' => $response->raw_body);
} else {
update_option('sendgrid_curl_option', 'disabled');
foreach ($files as $key => $value) {
unset($form[$value]);
}
$data = array('body' => $form);
$response = wp_remote_post($url, $data);
}
} else {
$data = array('body' => $form);
$response = wp_remote_post($url, $data);
}
return $response;
}