docomoへリクエストを送信し、対話内容を得る

@return Response|false
353820
public function request()
    {
        $reqUrl = sprintf('%s?APIKEY=%s', self::END_POINT_URL, rawurlencode($this->apikey));
        $reqBody = json_encode($this->getParameter()->makeParameter());

        $curl = new Curl();
        $curl->setHeader('Content-Type', 'application/json; charset=UTF-8');
        $ret = $curl->post($reqUrl, $reqBody);
        if ($curl->error) {
            trigger_error('docomo dialogue: Error ' . $curl->errorCode . ': ' . $curl->errorMessage, E_USER_WARNING);
            return false;
        }
        return new Response($ret);
    }
271725
public function validate(): bool
    {
        if (! $this->requestIsValid()) {
            return false;
        }

        $requestOptions = $this->getDefaultRequestOptions();
        $customOptions = $this->getCustomRequestOptions();

        if (! empty($customOptions) && is_array($customOptions)) {
            $requestOptions = array_merge($requestOptions, $customOptions);
        }

        $response = $this->guzzleClient->request('POST', self::OPENID_URL, $requestOptions);

        $results = $this->parseResults($response->getBody()->getContents());

        $this->parseSteamID();
        $this->parseInfo();

        return $results->is_valid == 'true';
    }
591006
public function methodNotAllowed(): Response
    {
        $this->response->setStatus(405);
        $this->response->setBody('<html><title>405 Method not allowed</title>405 Method not allowed</html>');
        return $this->response;
    }
624860
public static function getRequestAction()
    {
        $r = explode('/', ltrim(self::getRequestRoute(), '/'));
        return (isset($r[1]) && !empty($r[1])) ? $r[1] : false;
    }
270451
private function fetchResponse()
    {
        $type = $this->settings['type'];

        if (strpos('|INSERT|UPDATE|DELETE|REPLACE|', $type)) {
            if ($this->settings['result'] === 'id') {
                return $this->lastInsertId;
            }

            return $this->rowCount;
        } elseif ($type === 'SELECT') {
            if ($this->settings['result'] !== 'rows') {
                return $this->provider->fetchResponse(
                    $this->response,
                    $this->settings['result']
                );
            }
            if (is_object($this->response)) {
                return $this->provider->rowCount($this->response);
            }
        }

        return true;
    }
850411
public function getResponse()
	{
		$query = '';
		if (sizeof($this->parameters) > 0)
		{
			$query = substr($this->uri, -1) !== '?' ? '?' : '&';
			foreach ($this->parameters as $var => $value)
				if ($value == null || $value == '') $query .= $var.'&';
				else $query .= $var.'='.rawurlencode($value).'&';
			$query = substr($query, 0, -1);
			$this->uri .= $query;

			if (array_key_exists('acl', $this->parameters) ||
			array_key_exists('location', $this->parameters) ||
			array_key_exists('torrent', $this->parameters) ||
			array_key_exists('website', $this->parameters) ||
			array_key_exists('logging', $this->parameters))
				$this->resource .= $query;
		}
		$url = (S3::$useSSL ? 'https://' : 'http://') . ($this->headers['Host'] !== '' ? $this->headers['Host'] : $this->endpoint) . $this->uri;

		//var_dump('bucket: ' . $this->bucket, 'uri: ' . $this->uri, 'resource: ' . $this->resource, 'url: ' . $url);

		// Basic setup
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_USERAGENT, 'S3/php');

		if (S3::$useSSL)
		{
			// Set protocol version
			curl_setopt($curl, CURLOPT_SSLVERSION, S3::$useSSLVersion);

			// SSL Validation can now be optional for those with broken OpenSSL installations
			curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, S3::$useSSLValidation ? 2 : 0);
			curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, S3::$useSSLValidation ? 1 : 0);

			if (S3::$sslKey !== null) curl_setopt($curl, CURLOPT_SSLKEY, S3::$sslKey);
			if (S3::$sslCert !== null) curl_setopt($curl, CURLOPT_SSLCERT, S3::$sslCert);
			if (S3::$sslCACert !== null) curl_setopt($curl, CURLOPT_CAINFO, S3::$sslCACert);
		}

		curl_setopt($curl, CURLOPT_URL, $url);

		if (S3::$proxy != null && isset(S3::$proxy['host']))
		{
			curl_setopt($curl, CURLOPT_PROXY, S3::$proxy['host']);
			curl_setopt($curl, CURLOPT_PROXYTYPE, S3::$proxy['type']);
			if (isset(S3::$proxy['user'], S3::$proxy['pass']) && S3::$proxy['user'] != null && S3::$proxy['pass'] != null)
				curl_setopt($curl, CURLOPT_PROXYUSERPWD, sprintf('%s:%s', S3::$proxy['user'], S3::$proxy['pass']));
		}

		// Headers
		$headers = array(); $amz = array();
		foreach ($this->amzHeaders as $header => $value)
			if (strlen($value) > 0) $headers[] = $header.': '.$value;
		foreach ($this->headers as $header => $value)
			if (strlen($value) > 0) $headers[] = $header.': '.$value;

		// Collect AMZ headers for signature
		foreach ($this->amzHeaders as $header => $value)
			if (strlen($value) > 0) $amz[] = strtolower($header).':'.$value;

		// AMZ headers must be sorted
		if (sizeof($amz) > 0)
		{
			//sort($amz);
			usort($amz, array(&$this, '__sortMetaHeadersCmp'));
			$amz = "\n".implode("\n", $amz);
		} else $amz = '';

		if (S3::hasAuth())
		{
			// Authorization string (CloudFront stringToSign should only contain a date)
			if ($this->headers['Host'] == 'cloudfront.amazonaws.com')
				$headers[] = 'Authorization: ' . S3::__getSignature($this->headers['Date']);
			else
			{
				$headers[] = 'Authorization: ' . S3::__getSignature(
					$this->verb."\n".
					$this->headers['Content-MD5']."\n".
					$this->headers['Content-Type']."\n".
					$this->headers['Date'].$amz."\n".
					$this->resource
				);
			}
		}

		curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($curl, CURLOPT_HEADER, false);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
		curl_setopt($curl, CURLOPT_WRITEFUNCTION, array(&$this, '__responseWriteCallback'));
		curl_setopt($curl, CURLOPT_HEADERFUNCTION, array(&$this, '__responseHeaderCallback'));
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

		// Request types
		switch ($this->verb)
		{
			case 'GET': break;
			case 'PUT': case 'POST': // POST only used for CloudFront
				if ($this->fp !== false)
				{
					curl_setopt($curl, CURLOPT_PUT, true);
					curl_setopt($curl, CURLOPT_INFILE, $this->fp);
					if ($this->size >= 0)
						curl_setopt($curl, CURLOPT_INFILESIZE, $this->size);
				}
				elseif ($this->data !== false)
				{
					curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb);
					curl_setopt($curl, CURLOPT_POSTFIELDS, $this->data);
				}
				else
					curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb);
			break;
			case 'HEAD':
				curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD');
				curl_setopt($curl, CURLOPT_NOBODY, true);
			break;
			case 'DELETE':
				curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
			break;
			default: break;
		}

		// Execute, grab errors
		if (curl_exec($curl))
			$this->response->code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
		else
			$this->response->error = array(
				'code' => curl_errno($curl),
				'message' => curl_error($curl),
				'resource' => $this->resource
			);

		@curl_close($curl);

		// Parse body into XML
		if ($this->response->error === false && isset($this->response->headers['type']) &&
		$this->response->headers['type'] == 'application/xml' && isset($this->response->body))
		{
			$this->response->body = simplexml_load_string($this->response->body);

			// Grab S3 errors
			if (!in_array($this->response->code, array(200, 204, 206)) &&
			isset($this->response->body->Code, $this->response->body->Message))
			{
				$this->response->error = array(
					'code' => (string)$this->response->body->Code,
					'message' => (string)$this->response->body->Message
				);
				if (isset($this->response->body->Resource))
					$this->response->error['resource'] = (string)$this->response->body->Resource;
				unset($this->response->body);
			}
		}

		// Clean up file resources
		if ($this->fp !== false && is_resource($this->fp)) fclose($this->fp);

		return $this->response;
	}
876962
public function tokenAction()
    {
        $request = $this->getRequest();
        if (! $request instanceof HttpRequest) {
            // not an HTTP request; nothing left to do
            return;
        }

        if ($request->isOptions()) {
            // OPTIONS request.
            // This is most likely a CORS attempt; as such, pass the response on.
            return $this->getResponse();
        }

        $oauth2request = $this->getOAuth2Request();
        
        $response = $this->server->handleTokenRequest($oauth2request);
        if ($response->isClientError()) {
            $parameters = $response->getParameters();
            $errorUri   = isset($parameters['error_uri']) ? $parameters['error_uri'] : null;
            return new ApiProblemResponse(
                new ApiProblem(
                    $response->getStatusCode(),
                    $parameters['error_description'],
                    $errorUri,
                    $parameters['error']
                )
            );
        }
        return $this->setHttpResponse($response);
    }
720068
public function contentUriAction()
    {
        $actual = $this->getSubDomainModel()
                       ->findActual();

        if ( empty( $actual ) )
        {
            $this->getResponse()
                 ->setStatusCode( 404 );

            return;
        }

        $uri = $this->params()
                    ->fromRoute( 'uri' );

        // prevent "Invalid Encoding Attack"
        if ( ! mb_check_encoding( $uri, 'UTF-8' ) )
        {
            $this->getResponse()
                 ->setStatusCode( 404 );

            return;
        }

        $structure = $this->getUriModel()
                          ->findBySubdomainUri( $actual->id, $uri );

        if ( empty( $structure ) )
        {
            $this->paragraphLayout();

            $this->getResponse()
                 ->setStatusCode( 404 );

            return;
        }

        if ( ! $structure->default )
        {
            $default = $this->getUriModel()
                            ->findDefaultByContentSubdomain(
                                $structure->contentId,
                                $actual->id,
                                $structure->locale
                            );

            if ( $default->uri != $structure->uri ) // Avoid infinite redirect circles
            {
                $response = $this->getResponse();

                $response->getHeaders()
                         ->addHeaderLine( 'Location',
                                          '/' . $default->safeUri );

                // Permanent redirect: for "old" uris
                return $response->setStatusCode( 301 );
            }
        }

        if ( ! empty( $structure->locale ) )
        {
            $this->getServiceLocator()
                 ->get( 'Locale' )
                 ->setCurrent( $structure->locale );
        }

        return $this->forward()
                    ->dispatch( 'Grid\Paragraph\Controller\Render', array(
                        'controller'    => 'Grid\Paragraph\Controller\Render',
                        'action'        => 'paragraph',
                        'locale'        => (string) $this->locale(),
                        'paragraphId'   => $structure->contentId
                    ) );
    }
824780
public function enviar()
    {
        if ($this->enviado) {
            return false;
        }

        http_response_code($this->estadoHttp);

        // Enviamos cabeceras
        foreach ($this->cabeceras as $cabecera => $valores) {
            foreach ($valores as $valor) {
                header($cabecera . ': ' . $valor, false);
            }
        }

        if (!empty($this->contenido)) {
            echo $this->contenido;
        }

        return $this->enviado = true;
    }
674655
public function listAction()
    {
        $this->checkAuth($this->resources, $this->modules, AccessManager::VIEW);
        $request = $this->getRequest();

        if ($request->query->has('id')) {
            $request->query->remove('id');
        }

        $params = array_merge(
            $this->defaultLoopArgs,
            $request->query->all()
        );

        try {
            $results = $this->getLoopResults($params);
        } catch (\Exception $e) {
            throw new HttpException(500, json_encode(["error" => $e->getMessage()]));
        }

        return JsonResponse::create($results);
    }
1096789
protected function doIt()
    {

        $request = Craft::$app->getRequest();

        if ($request->getIsAjax()) {

            if (!$request->getIsPost()) {
                return false;
            }

            $segments = $request->segments;
            $actionSegment = $segments[count($segments) - 1];

            if ($actionSegment !== 'get-editor-html') {
                return false;
            }

            Craft::$app->getView()->registerJs('Craft.CpFieldInspectPlugin.initElementEditor();');

        } else {

            $data = array(
                'redirectUrl' => Craft::$app->getSecurity()->hashData(implode('/', $request->segments)),
                'fields' => array(),
                'entryTypeIds' => array(),
                'baseEditFieldUrl' => rtrim(UrlHelper::cpUrl('settings/fields/edit'), '/'),
                'baseEditEntryTypeUrl' => rtrim(UrlHelper::cpUrl('settings/sections/sectionId/entrytypes'), '/'),
                'baseEditGlobalSetUrl' => rtrim(UrlHelper::cpUrl('settings/globals'), '/'),
                'baseEditCategoryGroupUrl' => rtrim(UrlHelper::cpUrl('settings/categories'), '/'),
                'baseEditCommerceProductTypeUrl' => rtrim(UrlHelper::cpUrl('commerce/settings/producttypes'), '/'),
            );

            $sectionIds = Craft::$app->getSections()->getAllSectionIds();
            foreach ($sectionIds as $sectionId)
            {
                $entryTypes = Craft::$app->getSections()->getEntryTypesBySectionId($sectionId);
                $data['entryTypeIds']['' . $sectionId] = array();
                foreach ($entryTypes as $entryType)
                {
                    $data['entryTypeIds']['' . $sectionId][] = $entryType->id;
                }
            }


            $fields = Craft::$app->getFields()->getAllFields();

            foreach ($fields as $field)
            {

                $data['fields'][$field->handle] = array(
                    'id' => $field->id,
                    'handle' => $field->handle,
                );
            }

            Craft::$app->getView()->registerAssetBundle(CpFieldInspectBundle::class);
            Craft::$app->getView()->registerJs('Craft.CpFieldInspectPlugin.init('.json_encode($data).');');
        }
    }
926652
public function search()
    {
        if($this->request->isAjax())
        {
            $data = $this->doc->searchList($this->request->param('query'));
            return response($data, 200, [], 'json');
        }
        else
        {
            $module = $this->doc->getModuleList();
            return $this->show('search', ['module' => $module]);
        }
    }
138948
public function request() {
		if(!($vs_method = $this->getRequestMethod())) {
			return false;
		}

		$va_get = array();
		foreach($this->getAllGetParameters() as $vs_name => $vs_val) {
			$va_get[] = $vs_name."=".urlencode($vs_val);
		}

		if(strlen($this->ops_auth_token) > 0) {
			$va_get[] = 'authToken='.$this->ops_auth_token;
		}

		$vs_get = sizeof($va_get)>0 ? "?".join("&",$va_get) : "";

		$vs_query_url = preg_replace("/\/$/", '', $this->ops_service_url."/".$this->getEndpoint().$vs_get);
		$vo_handle = curl_init($vs_query_url);

		curl_setopt($vo_handle, CURLOPT_CUSTOMREQUEST, $vs_method);
		curl_setopt($vo_handle, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($vo_handle, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($vo_handle, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($vo_handle, CURLOPT_FOLLOWLOCATION, true);

		$va_body = $this->getRequestBody();
		if(is_array($va_body) && sizeof($va_body)>0) {
			curl_setopt($vo_handle, CURLOPT_POSTFIELDS, json_encode($va_body));
		}

		$vs_exec = curl_exec($vo_handle);
		$vn_code = curl_getinfo($vo_handle, CURLINFO_HTTP_CODE);
		curl_close($vo_handle);

		if($vn_code == 401) { // try to re-authenticate if access denied
			// discard previous token
			if(strlen($this->ops_auth_token)) {
				@file_put_contents($this->ops_token_storage_path, '');
			}

			if(!$this->authenticate()) { // make up json result for failed authentication
				return new ServiceResult('{ "ok": false, "errors": ["access denied"] }');
			} else { // auth successful, try again
				return $this->request();
			}
		}

		return new ServiceResult($vs_exec);
	}
573787
public function getReply()
    {
        if (!empty($this->reply)) {
            $reply = '';
            if (!empty($this->reply[1])) {
                $reply .= $this->addEncodeTag('"' . $this->reply[1] . '"') . ' ';
            }
            $reply .= '<' . $this->reply[0] . '>';
            return $reply;
        } else {
            return false;
        }
    }
436859
protected function doDropboxApiRequest()
    {
        $request = empty($this->request) ? [] : ['json' => $this->request];

        try {
            $response = $this->client->post("{$this->apiUrl}{$this->apiEndpoint}", $request);
        } catch (HttpClientException $exception) {
            throw $this->determineException($exception);
        }

        return json_decode($response->getBody(), true);
    }
249841
public function httpResponse()
    {
        // get the template
        $template = $this->view()->getTemplate();

        // if there is no template, then we return false
        if(empty($template)) {
            return false;
        }

        // get view data
        $viewData = $this->view()->getAssignedData();

        // assign application data to view
        $viewData['App'] = [
            'Config'       => $this->getEnvironmentConfig(),
            'Components'   => $this->environment->getComponentConfigs()->toArray(),
            'Environment'  => $this->getEnvironmentName(),
            'AbsolutePath' => $this->getAbsolutePath(),
            'WebPath'      => $this->getWebPath()
        ];

        // render the view and assign it to the response object
        return new Response($this->getTemplateEngineInstance()->fetch($this->view()->getTemplate(), $viewData));
    }
1130249
public function isRedirect()
    {
        $request = $this->request->getData();
        $response = $this->getData();

        return
            $request['opcode'] === 0 &&
            $response['extended_status'] === '3DSECURE';
    }