简体   繁体   English

如何使用 WP Webhooks 和 Wordpress 的自定义操作功能将响应数据发送回 Zapier?

[英]How do I get response data sent back to Zapier using the Custom Action function with WP Webhooks and Wordpress?

I'm trying to generate a Zoom SDK signature using my wordpress custom function.php file.我正在尝试使用我的 wordpress 自定义 function.php 文件生成 Zoom SDK 签名。 I am able to send a post to WP Webhooks using Zapier to fire a Custom Function.我可以使用 Zapier 将帖子发送到 WP Webhooks 以触发自定义函数。 I use the identifier and get the response "success, custom action successfully fired."我使用标识符并得到响应“成功,自定义操作成功触发”。 However, it will not return the SDK signature to Zapier.但是,它不会将 SDK 签名返回给 Zapier。

This is the PHP code that is run on a custom action.这是针对自定义操作运行的 PHP 代码。

 function generate_signature ( $api_key, $api_secret, $meeting_number, $role){
   //Set the timezone to UTC
   date_default_timezone_set("UTC");
    $time = time() * 1000 - 30000;//time in milliseconds (or close enough)
    $data = base64_encode($api_key . $meeting_number . $time . $role);
    $hash = hash_hmac('sha256', $data, $api_secret, true);
    $_sig = $api_key . "." . $meeting_number . "." . $time . "." . $role . "." . base64_encode($hash);
     //return signature, url safe base64 encoded
     return rtrim(strtr(base64_encode($_sig), '+/', '-_'), '=');

} }

I've also tried returning the data using the $return_args portion of the sample code provided by WP Webhooks.我还尝试使用 WP Webhooks 提供的示例代码的 $return_args 部分返回数据。 The sample code is below:示例代码如下:

 add_filter( 'wpwhpro/run/actions/custom_action/return_args', 'wpwh_fire_my_custom_logic', 10, 3 );
 function wpwh_fire_my_custom_logic( $return_args, $identifier, $response_body ){

    //If the identifier doesn't match, do nothing
    if( $identifier !== 'ilovewebhooks' ){
        return $return_args;
     }

    //This is how you can validate the incoming value. This field will return the value for the key user_email
    $email = WPWHPRO()->helpers->validate_request_value( $response_body['content'], 'user_email' );

    //Include your own logic here....

    //This is what the webhook returns back to the caller of this action (response)
    //By default, we return an array with success => true and msg -> Some Text
    return $return_args;

 }

I'm not sure how to format this code properly to fire the code given above to generate the SDK signature, and then return that within the $return_args back to the webhook that called it by Zapier?我不确定如何正确格式化此代码以触发上面给出的代码以生成 SDK 签名,然后在 $return_args 中将其返回给 Zapier 调用它的 webhook?

Thank you for any help you can provide!感谢您提供任何帮助!

You can just return the data by assigning the function response to the $return_args :您可以通过将函数响应分配给$return_args来返回数据:

    $return_args['data'] = generate_signature();

In your full example, it looks something like this:在您的完整示例中,它看起来像这样:

add_filter( 'wpwhpro/run/actions/custom_action/return_args', 'wpwh_fire_my_custom_logic', 10, 3 );
 function wpwh_fire_my_custom_logic( $return_args, $identifier, $response_body ){
    //If the identifier doesn't match, do nothing
    if( $identifier !== 'ilovewebhooks' ){
        return $return_args;
     }

    //This is how you can validate the incoming value. This field will return the value for the key user_email
    $email = WPWHPRO()->helpers->validate_request_value( $response_body['content'], 'user_email' );

    $return_args['data'] = generate_signature();

    //This is what the webhook returns back to the caller of this action (response)
    //By default, we return an array with success => true and msg -> Some Text
    return $return_args;

 }

You'll find more details about that here: https://wp-webhooks.com/integrations/wordpress/actions/custom_action/您将在此处找到更多详细信息: https ://wp-webhooks.com/integrations/wordpress/actions/custom_action/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 WordPress 中使用 wp_get_nav_menu_items 生成自定义菜单/子菜单系统? - How do I generate a custom menu/sub-menu system using wp_get_nav_menu_items in WordPress? 如何使用$ _GET获取WordPress自定义函数,并使用urlencode中的ID返回值? - How do I get a Wordpress custom function using $_GET to return a value using an id from a urlencode? 如何通过wordpress api请求从对象发送的响应中获得响应 - How do I get response from object sent via a request with wordpress api 如何读取webhooks发送的数据? - How to read data sent by webhooks? 如何在 Wordpress 中创建自定义 webhook,特别是对于 WooCommerce 操作? - How can I create custom webhooks in Wordpress, particularly for WooCommerce actions? 如何使用PHP中的setInterval函数从数据库获取数据 - How do I get data back from database using setInterval function in php 如何调用PHP类中的自定义函数(wordpress do_action样式)? - How can I call a custom function that is part of a class in PHP (wordpress do_action style)? 如何让我的 Wordpress(wp_query - 自定义帖子类型)、isotope.js 和 Bootstrap 过滤器正确显示? - How do I get my Wordpress (wp_query - custom post type), isotope.js, and Bootstrap filter to display correctly? 如何在WordPress中编写自定义函数? - How do I write a custom function in WordPress? 如何为 WC WP 制作此自定义 function? - How do I make this custom function for WC WP?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM