如果必须使用php执行此操作,则需要使用WP_Http
class. 具体来说,您可能想使用wp_remote_post()
. 像这样的事情应该让你开始。
function pushData($data){ //data is an associative array of the things you want to send
$url = "https://yourhost.com/your_catch_script.php";
return wp_remote_post($url, array(
\'method\' => \'POST\',
\'timeout\' => 45,
\'redirection\' => 5,
\'httpversion\' => \'1.0\',
\'blocking\' => true,
\'headers\' => array(),
\'body\' => $data,
\'cookies\' => array()
)
}
您可能需要对
$data
确保它是一个数组,并且包含适合写入数据库的值。
根据您的具体需要,您最好只进行某种数据库复制,您可以找到一个很好的解释来说明如何进行复制here.