Frage

I'm using the Podio PHP API, and I want to validate a webhook as done here: https://developers.podio.com/examples/webhooks

I have a test script on my server: http://qvido.se/api/podio/ValidateHook.php which contains this code:

<?php
    require_once('Depend/PodioAPI.php');
    require_once('Depend/config.php');

    error_log("validate triggerd");

    // Setup client
    Podio::setup($client_id, $client_secret);

    // Turn on debugging
    Podio::$debug = true;

    // Authenticate the application
    Podio::authenticate('app', array('app_id' => MY_APP_ID, 'app_token' => 'MY_APP_TOKEN'));

    switch ($_POST['type']) {
        case 'hook.verify':
            // Validate the webhook
          PodioHook::validate($_POST['hook_id'], array('code' => $_POST['code']));
        case 'item.create':
            // Do something. item_id is available in $_POST['item_id']
        case 'item.update':
            // Do something. item_id is available in $_POST['item_id']
        case 'item.delete':
            // Do something. item_id is available in $_POST['item_id']
    }
?>

When hitting Verfiy in the Podio UI it doesn't seem to send a $_POST request to my script. I've turned on the debug mode but nothing gets logged in the podio.log file. Instead it shows a 302 error code while trying to send the $_POST request to my script.

I don't think my script gets called at all. How can I do this?

War es hilfreich?

Lösung

Assuming all other variables are defined properly, there is still an error in your static Podio::authenticate() method.

Just strip the quotes from MY_APP_TOKEN:

So

    Podio::authenticate('app', array('app_id' => MY_APP_ID, 'app_token' => 'MY_APP_TOKEN'));

should better be

   Podio::authenticate('app', array('app_id' => MY_APP_ID, 'app_token' => MY_APP_TOKEN));

Cheers!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top