在我的functions.php文件中,我有以下内容(来自重力形式):
add_action('gform_after_submission_500', 'post_to_third_party', 10, 2);
function post_to_third_party($entry, $form) {
$post_url = THEME_DIR . '/myscript/index.php';
$body = array(
'first_name' => $entry['1'],
'last_name' => $entry['2'],
'email' => $entry['3']
);
$request = new WP_Http();
$response = $request->post($post_url, array('body' => $body));
}
我应该在&mys; / index.php'接收帖子数据以便我可以使用它?
答案 0 :(得分:0)
试试这个:
$request->request( $post_url, array( 'method' => 'POST', 'body' => $body) );
答案 1 :(得分:0)
/myscript/index.php
返回的数据只需要采用PHP在$response
变量中返回时可以处理的格式。我不是这里的专家,但我的默认设置是在/myscript/index.php
侧通过json_encode将数据输出为JSON,然后在json_decode中通过{{3}}解析数据响应。
$data = json_decode( wp_remote_retrieve_body( $response ) );