Hooks - Use a function that's required an authentication ?
Hi, I'm trying to active hooks to syncronise directly invoice from Podio to our system. I'm blocked because I try to use this code . It's seem that connection is required but... this code is called by the hook...How can I do that ? if(Podio::authenticate_with_app('ID APP', 'APP KEY')){ switch ($_POST['type']) { case 'item.create': $oInvoice = PodioItem::get($_POST['item_id']); // get complete Podio object PodioInvoiceGenerator::generateInvoice($oInvoice); // create our invoice break; case 'item.update': $oInvoice = PodioItem::get($_POST['item_id']); // get complete Podio object PodioInvoiceGenerator::generateInvoice($oInvoice); // update invoice break; case 'item.delete': $oInvoiceEmu = PodioInvoice::getInvoiceByPodioId($_POST['item_id']); // get our invoice $oInvoiceEmu->delete(); // delete invoice break; }}else { Log::error('connection with app fail '); }    

  • For information, I found somes errors...Here is the final code for example.If it helps someone... //Podio::$debug = true;Podio::setup(PodioConfig::APPKEY, PodioConfig::APPSECRET);try { Podio::authenticate('app', array('app_id' => $iApp, 'app_token' => $iAppToken)); // looks better switch ($_POST['type']) { case 'hook.verify': PodioHook::validate($_POST['hook_id'], array('code' => $_POST['code'])); // validate the hook break; case 'item.create': $oInvoice = PodioItem::get($_POST['item_id']); if($oInvoice) { // You got the object. Do something.  } break; case 'item.update': $oInvoice = PodioItem::get($_POST['item_id']); if($oInvoice){ // you got the object. Do something. } break; case 'item.delete': // ... break; }} catch ( PodioError $e ) { Log::error('hook fail ' . print_r($e,true));}
This question is closed.