wp_safe_remote_post

函式
wp_safe_remote_post ( $url, $args = array() )
引數
  • (string) $url URL to retrieve.
    Required:
  • (array) $args Optional. Request arguments. Default empty array.
    Required:
    Default: array()
返回值
  • (array|WP_Error) The response or WP_Error on failure.
相關
  • wp_remote_request()
  • WP_Http::request()
定義位置
相關方法
wp_safe_remote_getwp_remote_postwp_safe_remote_requestwp_safe_remote_headwp_insert_post
引入
3.6.0
棄用
-

wp_safe_remote_post: 這是一個WordPress函式,用於安全地釋出資料到一個URL。它使用wp_safe_remote_request函式來發布資料並驗證SSL證書,防止中間人攻擊。

檢索使用POST方法的安全HTTP請求的原始響應。

當HTTP請求被髮送到一個任意的URL時,這個函式是理想的。該URL被驗證以避免重定向和請求偽造攻擊。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_safe_remote_post( $url, $args = array() ) {
$args['reject_unsafe_urls'] = true;
$http = _wp_http_get_object();
return $http->post( $url, $args );
}
function wp_safe_remote_post( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; $http = _wp_http_get_object(); return $http->post( $url, $args ); }
function wp_safe_remote_post( $url, $args = array() ) {
	$args['reject_unsafe_urls'] = true;
	$http                       = _wp_http_get_object();
	return $http->post( $url, $args );
}

常見問題

FAQs
檢視更多 >