当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::forge方法代码示例

本文整理汇总了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;
 }
开发者ID:eva-bi,项目名称:coupon,代码行数:32,代码来源:home.php

示例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();
             }
         }
     }
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:37,代码来源:Base.php

示例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;
 }
开发者ID:jupitern,项目名称:fuelphp-1.7.2,代码行数:31,代码来源:google.php

示例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;
 }
开发者ID:indigophp,项目名称:erp-stock-extra,代码行数:13,代码来源:request.php

示例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,
			),
		);
	}
开发者ID:rob-mccann,项目名称:fuel-oauth,代码行数:28,代码来源:twitter.php

示例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'],
			),
		);
	}
开发者ID:rob-mccann,项目名称:fuel-oauth,代码行数:26,代码来源:linkedin.php

示例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;
 }
开发者ID:rob-mccann,项目名称:fuel-amazon-ses,代码行数:37,代码来源:ses.php

示例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;
 }
开发者ID:rob-mccann,项目名称:fuel-urlshortener,代码行数:33,代码来源:bitly.php

示例9: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     // reset Request::$main
     $request = \Request::forge();
     $rp = new \ReflectionProperty($request, 'main');
     $rp->setAccessible(true);
     $rp->setValue($request, false);
 }
开发者ID:wushian,项目名称:MDD,代码行数:8,代码来源:fieldset.php

示例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;
 }
开发者ID:daniel-rodas,项目名称:rodasnet.com,代码行数:9,代码来源:admin.php

示例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);
 }
开发者ID:rainyman2012,项目名称:fuel-oauth,代码行数:10,代码来源:dropbox.php

示例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);
 }
开发者ID:daniel-rodas,项目名称:rodasnet.com,代码行数:10,代码来源:service.php

示例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'));
 }
开发者ID:rainyman2012,项目名称:fuel-oauth,代码行数:10,代码来源:flickr.php

示例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();
 }
开发者ID:mp-php,项目名称:fuel-packages-chatwork,代码行数:19,代码来源:chatwork.php

示例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));
 }
开发者ID:daniel-rodas,项目名称:rodasnet.com,代码行数:11,代码来源:image.php


注:本文中的Request::forge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。