Beispiel #1
0
            case "UPDATE":
                updateBlog($_REQUEST);
                $results = getAllBlogs("all");
                break;
            case "DELETE":
                deleteBlog($_REQUEST['code']);
                $results = getProductsDB("all");
                break;
            case "search":
                $results = getSearchDB($_REQUEST['search']);
                break;
            default:
                //if the specified action isn't recognised set meta details
                $results["meta"]["msg"] = "action not recognised, illegal action!";
                $results["meta"]["status"] = 400;
                $results["meta"]["ok"] = false;
        }
        break;
    default:
        //if the verb isn't supported or recognised set meta details
        $results["meta"]["msg"] = "Verb not recognised or is not supported!";
        $results["meta"]["status"] = 400;
        $results["meta"]["ok"] = false;
}
if (!($results == null)) {
    //encodes the results into JSON format and sets the header (echos)
    encodeResults($results);
} else {
    //echos plain text
    resultsEmpty($results);
}
Beispiel #2
0
    return $slackMessage;
}
function sendAnalyticsEvent()
{
    #Send an event to GA using the Measurement Protocol#
    #Set up variables
    $UANumber = 'UA-67891724-1';
    $eventCategory = 'script';
    $eventAction = $_POST['command'];
    $eventLabel = $_POST['channel_name'];
    $eventSource = 'slack';
    $eventMedium = 'script';
    $clientID = uniqid();
    #UUID v4
    $userID = md5($_POST['user_name']);
    #Construct URL for Analytics Measurement Protocol
    $baseURL = "http://www.google-analytics.com/collect";
    $payload = "?v=1&tid={$UANumber}&t=event&ec={$eventCategory}&ea={$eventAction}&el={$eventLabel}&cs={$eventSource}&cm={$eventMedium}&cid={$clientID}&uid={$userID}";
    #to add Client ID once implemented
    $requestURL = $baseURL . $payload;
    #Make request to send event
    file_get_contents($requestURL);
}
$analytics = getService();
$profile = getFirstProfileId($analytics);
$results = getResults($analytics, $profile);
$text = encodeResults($results);
#echo($text);
$response = buildSlackMessage($text);
echo $response;
sendAnalyticsEvent();