Ejemplo n.º 1
0
 public function testSetBadURL()
 {
     $instance = new Socialworth();
     try {
         $instance->url($this->test_bad_url);
         $instance->twitter();
     } catch (\InvalidArgumentException $e) {
         $this->assertTrue(true);
         return;
     }
     $this->fail(_("Bad URL was accepted as valid."));
 }
Ejemplo n.º 2
0
use Evansims\Socialworth;
// Command Line
if (PHP_SAPI == 'cli' && isset($argv) && count($argv > 1)) {
    header("Content-Type: text/plain");
    $instance = new Socialworth();
    $services = array();
    $response = array('total' => 0);
    for ($i = 1; $i < count($argv); $i++) {
        $arg = $argv[$i];
        if (substr($arg, 0, 2) == '--') {
            $arg = substr($arg, 2);
            if (isset($instance->services[$arg])) {
                $services[] = $arg;
            }
        } elseif (filter_var($arg, FILTER_VALIDATE_URL)) {
            $instance->url($arg);
        }
    }
    if ($services) {
        foreach ($services as $service) {
            $response[$service] = $instance->{$service};
            $response['total'] += $response[$service];
        }
    } else {
        $response = $instance->all();
    }
    echo json_encode($response, JSON_PRETTY_PRINT);
    exit;
}
// Script queried directly
if (isset($_GET['url'])) {