[英]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.