• I’ve installed WP Webhooks at my online server. From dashboard, I got the api key :
    whpro_api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    But when I try to post requset, I got this reply: “The given WP Webhooks Pro API Key is not valid, please enter a valid API key and”.

    I’ve tried to post following data through php cURL,

              'type' =>'room_init',
    	  'token'=>'example-token-ODcdPc',
    	  'userid'=> 'example-user-tEzhcA',
    	  'timestamp' =>'2020-05-19T16:01:49.157Z'

    When I try using localhost with another api key, the server replies that custom action si successfully fired. But in web server it shows api key isn’t valid.

    My code:

    <?php
    
    $url= 'https://localhost/wordpress/class/?action=custom_action&wpwhpro_action=class_link&wpwhpro_api_key=xxxxxxxxxxxxxxxxxxxxxxxx';
    
    $url='https://pias.epizy.com/wp/?action=custom_action&wpwhpro_action=class_link&wpwhpro_api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
    
    //Initiate cURL.
    $ch = curl_init($url);
    
    //The JSON data.
    
    $wp_webhooks= array(
    
    	'type' =>'room_init',
    	'token'=>'example-token-ODcdPc',
    	'userid'=> 'example-user-tEzhcA',
    	'timestamp' =>'2020-05-19T16:01:49.157Z'
    );
    
    //Encode the array into JSON.
    $jsonDataEncoded = json_encode($wp_webhooks);
    
    //Tell cURL that we want to send a POST request.
    curl_setopt($ch, CURLOPT_POST, 1);
    
    //Attach our encoded JSON string to the POST fields.
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
    
    //Set the content type to application/json
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    
    //Execute the request
    $response = curl_exec($ch);
    
    curl_close($ch);
    
    // Check for errors
    if($response === FALSE){
        die('Error');
    }
    else
    {
    echo $response;
    }
    
    // Decode the response
    $responseData = json_decode($response, TRUE);
    
    print("<pre>".print_r($responseData,true)."</pre>");
    
    ?>
    • This topic was modified 4 years, 6 months ago by mnhpias. Reason: typing mistake
    • This topic was modified 4 years, 6 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ironikus

    (@ironikus)

    Hey @mnhpias – thank you a lot for your message.

    A very important note upfront: Please never share your webhook API key/token publicly. After you read that, please change it immediately since this can cause security issues if you are not using other security measurements.
    In case you need to share the URL as like in this case, please reach out to us through our website at https://ironikus.com/contact
    For now, I asked the forum moderators to remove your sensitive data. ??

    To answer your issue:
    The URL you included within the URL field does not work, because it is not a properly encoded URL. After the token, your link starts again with a question mark (?type=room), which breaks the query and the URL won’t work anymore as expected.
    Please re-format the URL properly before trying it again.
    Without the parameters, the call works without any issue.

    If you have further questions, feel free to reach out at any time.

    • This reply was modified 4 years, 6 months ago by Ironikus.
Viewing 1 replies (of 1 total)
  • The topic ‘The given WP Webhooks Pro API Key is not valid, please enter a valid API key and’ is closed to new replies.