public function test() { //include all the source files $dirItterator = new \RecursiveDirectoryIterator(dirname(__FILE__) . "/../"); $iterator = new \RecursiveIteratorIterator($dirItterator, \RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file) { if ($file->isFile()) { $filePath = $file->getPathname(); if (strpos($filePath, ".php") && !strpos($filePath, "index.php")) { include_once $filePath; } } } //buid the data $postdata = array("key" => "somegoodkey", "data" => '{' . '"gmailUsername":"******",' . '"gmailPassword":"******",' . '"limit":3,' . '"twitterUsername":"******",' . '"twitterPassword":"******",' . '"twitterToAddress":"ENTER-HERE"' . '}'); //get the service $service = new \MailChirp\GmailWebService\Service($postdata); //run the service $return = $service->Run(); }
<?php header('Content-type: application/json'); //include all the source files $dirItterator = new \RecursiveDirectoryIterator(dirname(__FILE__)); $iterator = new \RecursiveIteratorIterator($dirItterator, \RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file) { if ($file->isFile()) { $filePath = $file->getPathname(); if (strpos($filePath, ".php") && !strpos($filePath, "index.php")) { include_once $filePath; } } } //Create a new service $service = new \MailChirp\GmailWebService\Service($_POST); //run the service $returnMessage = $service->Run(); //return the result echo $returnMessage;