public function actionJsonProxyPost()
	{
		$url = Cii::get($_POST, 'url', false);

		if ($url === false)
			throw new CHttpException(400, Yii::t('Api.index', 'Missing $_POST[url] parameter'));

		$hash = md5($url);
		$response = Yii::app()->cache->get('CiiMS::API::Proxy::'.$hash);

		if ($response == false)
		{
			$curl = new \Curl\Curl;			
			$response = serialize($curl->get($url));

			if ($curl->error)
				throw new CHttpException(500, Yii::t('Api.index', 'Failed to retrieve remote resource.'));

			$curl->close();

			Yii::app()->cache->set('API::Proxy::'.$hash, $response, 600);
		}
		
		return unserialize($response);
	}
public function actionJsonProxyPost()
	{
		$url = Cii::get($_POST, 'url', false);

		if ($url === false)
			throw new CHttpException(400, Yii::t('Api.index', 'Missing $_POST[url] parameter'));

		$hash = md5($url);
		$response = Yii::app()->cache->get('CiiMS::API::Proxy::'.$hash);

		if ($response == false)
		{
			$curl = new \Curl\Curl;			
			$response = serialize($curl->get($url));

			if ($curl->error)
				throw new CHttpException(500, Yii::t('Api.index', 'Failed to retrieve remote resource.'));

			$curl->close();

			Yii::app()->cache->set('API::Proxy::'.$hash, $response, 600);
		}
		
		return unserialize($response);
	}
public function actionJsonProxyPost ( ) { $ url = Cii :: get ( $ _POST , 'url' , false ) ; if ( $ url === false ) throw new CHttpException ( 400 , Yii :: t ( 'Api.index' , 'Missing $_POST[url] parameter' ) ) ; $ hash = md5 ( $ url ) ; $ response = Yii :: app ( ) -> cache -> get ( 'CiiMS::API::Proxy::' . $ hash ) ; if ( $ response == false ) { $ curl = new \ Curl \ Curl ; $ response = serialize ( $ curl -> get ( $ url ) ) ; if ( $ curl -> error ) throw new CHttpException ( 500 , Yii :: t ( 'Api.index' , 'Failed to retrieve remote resource.' ) ) ; $ curl -> close ( ) ; Yii :: app ( ) -> cache -> set ( 'API::Proxy::' . $ hash , $ response , 600 ) ; } return unserialize ( $ response ) ; }
Global proxy for CiiMS to support JavaScript endpoints that either don't have proper CORS headers or SSL
This endpoint will only process JSON, and will cache data for 10 minutes.
@return mixed
Global proxy for CiiMS to support JavaScript endpoints that either don t have proper CORS headers or SSL This endpoint will only process JSON and will cache data for 10 minutes .