微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Gravity Forms 提交给第三方从响应中检索值

如何解决Gravity Forms 提交给第三方从响应中检索值

我正在尝试使用 gform_after_submission 方法将我的表单数据提交给第三方 API,第一部分对我来说非常简单,但是在初始 API 调用后,将发送回包含 ID 值的响应,我然后需要使用响应中给出的 ID 值,然后在另一个 API 调用中发送。

请看下面我目前使用的代码

add_action( 'gform_after_submission','post_to_third_party',10,2 );
function post_to_third_party( $entry,$form ) {
 
    $endpoint_url = 'https://thirdparty.com';
    $body = array(
        'first_name' => rgar( $entry,'1.3' ),'last_name' => rgar( $entry,'1.6' ),'message' => rgar( $entry,'3' ),);
    GFCommon::log_debug( 'gform_after_submission: body => ' . print_r( $body,true ) );
 
    $response = wp_remote_post( $endpoint_url,array( 'body' => $body ) );
    GFCommon::log_debug( 'gform_after_submission: response => ' . print_r( $response,true ) );
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。