簡體   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?

我正在嘗試使用我的 wordpress 自定義 function.php 文件生成 Zoom SDK 簽名。 我可以使用 Zapier 將帖子發送到 WP Webhooks 以觸發自定義函數。 我使用標識符並得到響應“成功,自定義操作成功觸發”。 但是,它不會將 SDK 簽名返回給 Zapier。

這是針對自定義操作運行的 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), '+/', '-_'), '=');

}

我還嘗試使用 WP Webhooks 提供的示例代碼的 $return_args 部分返回數據。 示例代碼如下:

 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;

 }

我不確定如何正確格式化此代碼以觸發上面給出的代碼以生成 SDK 簽名,然后在 $return_args 中將其返回給 Zapier 調用它的 webhook?

感謝您提供任何幫助!

您可以通過將函數響應分配給$return_args來返回數據:

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

在您的完整示例中,它看起來像這樣:

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;

 }

您將在此處找到更多詳細信息: https ://wp-webhooks.com/integrations/wordpress/actions/custom_action/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM