簡體   English   中英

Wordpress wp_remote_post

[英]Wordpress wp_remote_post

我想使用wp_remote_post將信息從一個服務器發送到我的其他網站。

所以基本上,我已將此行添加到我的代碼中 -

$sidebarHTTP = site_url(); // Retrieves HTTP Url of sidebar
$sidebarActivation = $sidebar.' , '.$sidebarHTTP; // Activate Sidebar 
$args = array(
  'method' => 'post',
  'body' => array('sidebar' => $sidebar, 'sidebarHTTP' => $sidebarHTTP),
  'user-agent' => 'My site'
);
wp_remote_post( 'http://mysite.com', $args ); // Loads all default data   

所以基本上,它不發送任何東西。 是的,我輸入了正確的域名。 也許它確實發送了一些內容,但我不知道如何從該網站檢索$ args ['body']。 另外,我嘗試添加$ response = wp_remote_post ....然后發送郵件$ response ['body'],但它只是將主頁的源代碼發送到電子郵件。

很感激幫助。

您需要在php.ini文件中啟用cURL。

wp_remote_post()使用一個名為WP_Http的類,該類又可以使用三個傳輸類中的一個(請參閱文件class-http.php function _get_first_available_transport )。

POST方法適用於類WP_Http_Curl ,但不適用於類WP_Http_Streams (cURL回退)。

另一種方法是使用wp_remote_get()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM