public static function retrieve($endpoint, $params = null, $method = 'get') { $fs = new self(); $method = strtolower($method); switch ($method) { case 'get': return $fs->get($endpoint, $params); break; case 'post': return $fs->post($endpoint, $params); break; case 'delete': return $fs->delete($endpoint, $params); break; default: throw new ddFoursquareBadRequestException('The given method is invalid.'); } }
static function quickPost($url, $data) { $bits = parse_url($url); $host = $bits['host']; $port = isset($bits['port']) ? $bits['port'] : 80; $path = isset($bits['path']) ? $bits['path'] : '/'; $client = new self($host, $port); if (!$client->post($path, $data)) { return false; } else { return $client->getContent(); } }
public static function instantiate(User $user, $parent, $data) { $instance = new self(); $instance->author()->associate($user); if ($parent instanceof Post) { $instance->post()->associate($parent); } elseif ($parent instanceof Comment) { $instance->post_id = $parent->post_id; } $instance->fill($data)->save(); if ($parent instanceof Comment) { $instance->makeChildOf($parent); } return $instance; }