本文整理汇总了PHP中Request::forge方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::forge方法的具体用法?PHP Request::forge怎么用?PHP Request::forge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::forge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_search
public function action_search()
{
$coupons = "";
try {
$coupons = unserialize(Cache::get('cache_coupons'));
} catch (\CacheNotFoundException $e) {
$curl = Request::forge('http://allcoupon.jp/api-v1/coupon', 'curl');
$curl->set_params(array('output' => 'json', 'apikey' => '9EBgSyRbAPmutrWE'));
// this is going to be an HTTP POST
$curl->set_method('get');
$curl->set_auto_format(true);
$result = $curl->execute()->response();
$coupons = json_decode($result->body);
Cache::set('cache_coupons', serialize($coupons), 300);
}
if ($area = Input::get('area')) {
$coupons = array_filter($coupons, function ($v, $k) {
return $v->coupon_area == Input::get('area');
}, ARRAY_FILTER_USE_BOTH);
}
if ($category = Input::get('category')) {
$coupons = array_filter($coupons, function ($v, $k) {
return $v->category_name == Input::get('category');
}, ARRAY_FILTER_USE_BOTH);
}
$view = Presenter::forge('home/search');
$view->set('title', $area, false);
$view->set('area', $area, false);
$view->set('category', $category, false);
$view->set('coupons', $coupons, false);
$this->template->content = $view;
}
示例2: action_catchall
/**
* Will attempt to find an item based on the current URL, and route it through a controller before returning a 404 error
*
* @access public
* @return Response
*/
public function action_catchall()
{
// Will try to find the model based on the URL
$model = $this->model = \CMF::currentModel();
\CMF::$routed = true;
// Return the normal 404 error if not found
if (is_null($model)) {
$action = trim(\Input::uri(), '/');
if (!empty($action)) {
return \Request::forge('base/' . $action, false)->execute()->response();
}
return $this->show404();
}
// So the model was found - check if it has a controller to route to
$template = \CMF::$template;
$action = \CMF::$action;
if (\CMF::hasController($template)) {
$module = \CMF::$module;
$path = \CMF::$path;
$route = (empty($module) ? '' : $module . '/') . $path . (empty($action) ? '' : '/' . $action);
return \Request::forge($route, false)->execute()->response();
} else {
if (!empty($action)) {
return $this->show404();
} else {
if (\CMF::$root) {
return \Request::forge('base/' . $action, false)->execute()->response();
}
}
}
}
示例3: _execute
/**
* Gets data from Google calculator
*
* @return bool success boolean
*/
protected function _execute()
{
$currency_from = strtoupper($this->currency_from);
$currency_to = strtoupper($this->currency_to);
$amount = $this->amount;
$url = sprintf($this->url, $amount, $currency_from, $currency_to);
try {
$request = \Request::forge($url, 'curl')->execute();
} catch (\Exception $e) {
throw new \FuelException('_execute() error in driver : ' . $this->config['driver'] . '. Error message returned: ' . $e->getMessage());
}
if ($request and $request->response()->status === 200 and $request->response()->body()) {
$response = $request->response()->body();
$search = array('lhs', 'rhs', 'error', 'icc');
$replace = array('"lhs"', '"rhs"', '"error"', '"icc"');
$response = str_replace($search, $replace, $response);
$return = json_decode($response);
if (empty($return->error)) {
$result = (double) $return->rhs;
return $result;
}
} else {
throw new \FuelException('Got invalid status/body from ' . $this->config['driver']);
}
return false;
}
示例4: request
/**
* Create Request object
* @param string $url Resource URL
* @param array $options Array of options (must include driver)
* @return $this Returns this for method chaining
*/
protected function request($url, array $options = array())
{
empty($options['driver']) && ($options['driver'] = 'curl');
$this->request = \Request::forge($url, $options);
$this->get_config('auto_format', true) === false and $this->request->set_auto_format(false);
return $this;
}
示例5: get_user_info
public function get_user_info(Consumer $consumer, Token $token)
{
// Create a new GET request with the required parameters
$request = Request::forge('resource', 'GET', 'http://api.twitter.com/1/users/lookup.json', array(
'oauth_consumer_key' => $consumer->key,
'oauth_token' => $token->access_token,
'user_id' => $token->uid,
));
// Sign the request using the consumer and token
$request->sign($this->signature, $consumer, $token);
$user = current(json_decode($request->execute()));
// Create a response from the request
return array(
'uid' => $token->uid,
'nickname' => $user->screen_name,
'name' => $user->name ?: $user->screen_name,
'location' => $user->location,
'image' => $user->profile_image_url,
'description' => $user->description,
'urls' => array(
'Website' => $user->url,
'Twitter' => 'http://twitter.com/'.$user->screen_name,
),
);
}
示例6: get_user_info
public function get_user_info(Consumer $consumer, Token $token)
{
// Create a new GET request with the required parameters
$url = 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url)';
$request = Request::forge('resource', 'GET', $url, array(
'oauth_consumer_key' => $consumer->key,
'oauth_token' => $token->access_token,
));
// Sign the request using the consumer and token
$request->sign($this->signature, $consumer, $token);
$user = \Format::forge($request->execute(), 'xml')->to_array();
// Create a response from the request
return array(
'uid' => $user['id'],
'name' => $user['first-name'].' '.$user['last-name'],
'nickname' => end(explode('/', $user['public-profile-url'])),
'description' => $user['headline'],
'location' => \Arr::get($user, 'location.name'),
'urls' => array(
'Linked In' => $user['public-profile-url'],
),
);
}
示例7: _send
/**
* Sends the email using the Amazon SES email delivery system
*
* @return boolean True if successful, false if not.
*/
protected function _send()
{
$params = array('Action' => 'SendEmail', 'Source' => static::format_addresses(array($this->config['from'])), 'Message.Subject.Data' => $this->subject, 'Message.Body.Text.Data' => $this->alt_body, 'Message.Body.Html.Data' => $this->body);
$i = 0;
foreach ($this->to as $value) {
$params['Destination.ToAddresses.member.' . ($i + 1)] = static::format_addresses(array($value));
++$i;
}
$i = 0;
foreach ($this->cc as $value) {
$params['Destination.CcAddresses.member.' . ($i + 1)] = static::format_addresses(array($value));
++$i;
}
$i = 0;
foreach ($this->bcc as $value) {
$params['Destination.BccAddresses.member.' . ($i + 1)] = static::format_addresses(array($value));
++$i;
}
$i = 0;
foreach ($this->reply_to as $value) {
$params['ReplyToAddresses.member.' . ($i + 1)] = static::format_addresses(array($value));
++$i;
}
$date = date(DATE_RSS);
$signature = $this->_sign_signature($date);
$curl = \Request::forge('https://email.' . $this->region . '.amazonaws.com/', array('driver' => 'curl', 'method' => 'post'))->set_header('Content-Type', 'application/x-www-form-urlencoded')->set_header('X-Amzn-Authorization', 'AWS3-HTTPS AWSAccessKeyId=' . \Config::get('ses.access_key') . ', Algorithm=HmacSHA256, Signature=' . $signature)->set_header('Date', $date);
$response = $curl->execute($params);
if (intval($response->response()->status / 100) != 2) {
return false;
}
return true;
}
示例8: _expand
/**
* @return bool long url String
*/
protected function _expand($url)
{
$curl = \Request::forge('http://api.bitly.com/v3/expand', array('driver' => 'curl', 'method' => 'get', 'params' => array('format' => 'json', 'apikey' => \Config::get('urlshortener.accounts.bitly.api_key'), 'login' => \Config::get('urlshortener.accounts.bitly.login'), 'shorturl' => $url)));
$response = $curl->execute()->response();
if (intval($response->status / 100) != 2) {
throw new \Fuel_Exception('There was a problem expanding the url (' . $response->status . ')');
}
$data = json_decode($response->body);
switch ($data->status_code) {
case 200:
case 201:
$expanded = current($data->data->expand);
if (isset($expanded->error)) {
if ($expanded->error == 'NOT_FOUND') {
throw new NotFoundException('The short url could not be expanded because it doesn\'t exist');
}
throw new \Fuel_Exception('There was a problem expanding the url (' . $expanded->error . ')');
} else {
return $expanded->long_url;
}
break;
case 500:
case 401:
throw new \Fuel_Exception('Please set your bit.ly API key and login name in the config (' . $data->status_code . ')');
break;
default:
throw new \Fuel_Exception('There was a problem expanding the url (' . $data->status_code . ')');
}
return false;
}
示例9: tearDownAfterClass
public static function tearDownAfterClass()
{
// reset Request::$main
$request = \Request::forge();
$rp = new \ReflectionProperty($request, 'main');
$rp->setAccessible(true);
$rp->setValue($request, false);
}
示例10: action_post
public function action_post($add = null, $id = null)
{
if ($id) {
$view = \Request::forge('blog/backend/post/add/' . $id, false)->execute()->response()->body();
$this->template->content = $view;
}
$view = \Request::forge('blog/backend/post/add', false)->execute()->response()->body();
$this->template->content = $view;
}
示例11: get_user_info
public function get_user_info(Consumer $consumer, Token $token)
{
// Create a new GET request with the required parameters
$request = Request::forge('resource', 'GET', 'https://api.dropbox.com/0/account/info', array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token));
// Sign the request using the consumer and token
$request->sign($this->signature, $consumer, $token);
$user = json_decode($request->execute());
// Create a response from the request
return array('uid' => $token->uid, 'name' => $user->display_name, 'location' => $user->country);
}
示例12: action_index
public function action_index($ng_view = 'register')
{
$data = array();
$data['facebook_login'] = View::forge('user/facebook');
$data['form_create'] = Request::forge('user/auth/create', false)->execute()->response()->body();
$data['form_login'] = Request::forge('user/auth/login', false)->execute()->response()->body();
$data['form_recover'] = Request::forge('user/password/recover', false)->execute()->response()->body();
$authentication_forms = View::forge('user/service/index')->set('content', $data)->set('ng_view', $ng_view);
$this->template->content = View::forge('user/page')->set('header', $this->_header)->set('content', $authentication_forms);
}
示例13: get_user_info
public function get_user_info(Consumer $consumer, Token $token)
{
// Create a new GET request with the required parameters
$request = Request::forge('resource', 'GET', 'http://api.flickr.com/services/rest', array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token, 'nojsoncallback' => 1, 'format' => 'json', 'method' => 'flickr.test.login'));
// Sign the request using the consumer and token
$request->sign($this->signature, $consumer, $token);
$response = json_decode($request->execute(), true);
// Create a response from the request
return array('uid' => \Arr::get($response, 'user.id'), 'name' => \Arr::get($response, 'user.username._content'), 'nickname' => \Arr::get($response, 'user.username._content'));
}
示例14: call
/**
* Call API
*
* @param string $method
* @param string $uri
* @param array $params
* @return \Fuel\Core\Response
*/
protected static function call($method, $uri, array $params = array())
{
$curl = \Request::forge(static::$endpoint . $uri, 'curl');
$curl->set_mime_type('json')->set_method($method)->set_params($params)->set_header('X-ChatWorkToken', \Config::get('chatwork.api_token'));
try {
$curl->execute();
} catch (\Exception $e) {
// do nothing.
}
return $curl->response();
}
示例15: action_featured
public function action_featured($id = false)
{
$gallery = \Model_Gallery::query()->where('post_id', $id)->get_one();
if (!$gallery) {
return \Response::forge(\View::forge('frontend/post/show/image'));
}
$data['url'] = $gallery->asset->uri . '' . $gallery->asset->name;
$data['extension'] = $gallery->asset->type;
$this->data['image_url'] = \Request::forge('image/encoder/encodeBase64')->execute($data)->response()->body();
return \Response::forge(\View::forge('frontend/post/show/image')->set($this->data, null, false));
}