/**
 * Listen for API actions
 */
function listen_for_actions()
{
    $listener = new Listener(EDD_HELPSCOUT_API_PATH);
    $action = $listener->listen($_SERVER['REQUEST_URI']);
    if (!empty($action)) {
        /**
         * Perform an API action. Request is unauthorized at this point, so make sure to perform auth checks in your action callback.
         *
         * The dynamic portion of the hook, `$action`, refers to the name of the action.
         *
         * @see authorize_request
         * @see verify_request_signature
         */
        do_action('edd_helpscout_' . $action);
    }
}
Example #2
0
 private function listen($id)
 {
     if (!isset($id)) {
         return 401;
     } else {
         $listener = new Listener(array("type" => CONVERSATION));
         $response = $listener->listen();
         if (is_array($response)) {
             $output_array = array();
             foreach ($response as $v) {
                 if (is_array($v) && array_key_exists("thread", $v)) {
                     if ($v["thread"] == $id) {
                         array_push($output_array, $v);
                     }
                 }
             }
             return $output_array;
         } else {
             return $response;
         }
     }
 }
Example #3
0
switch ($lib) {
    case "item":
        $library = new Item($_GET);
        $return = $library->run();
        break;
    case "user":
        $library = new User($_GET);
        $return = $library->run(false);
        break;
    case "login":
        $library = new Login($_GET);
        $return = $library->run();
        break;
    case "listener":
        $library = new Listener($_GET);
        $return = $library->listen();
        break;
    case "messenger":
        $library = new Messenger($_GET);
        $return = $library->run();
        break;
    case "exchange":
        $library = new Exchange($_GET);
        $return = $library->run();
        break;
    case "feed":
        $library = new Feed($_GET);
        $return = $library->run();
        break;
    default:
        $return = 405;