Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 处理编码的服务器请求_Php_Swift_Laravel_Request - Fatal编程技术网

Php 处理编码的服务器请求

Php 处理编码的服务器请求,php,swift,laravel,request,Php,Swift,Laravel,Request,访问我的服务器的iPhone应用程序发送以下JSON编码的请求: 所以“?”将被“%3F”替换 但现在,我的服务器似乎出了问题。如何在路由或控制器中处理此编码请求以正确处理 Routes.php Route::get('/aeds', 'AED\APIAEDController@index'); 控制器 public function index(Request $request) { // Get Latitude and Longitude from request url

访问我的服务器的iPhone应用程序发送以下JSON编码的请求:

所以“?”将被“%3F”替换

但现在,我的服务器似乎出了问题。如何在路由或控制器中处理此编码请求以正确处理

Routes.php

Route::get('/aeds', 'AED\APIAEDController@index');
控制器

public function index(Request $request) {

    // Get Latitude and Longitude from request url
    $latitude = $request["latitude"];
    $longitude = $request["longitude"];
    $aeds = new AED();

    // In no latitude and longitude is provided in request, search for all aeds
    // If latitude and longitude is set in request, search for aeds in proximity of this location information
    if(!isset($latitude) & !isset($longitude)) {
        $aeds = $aeds->getAllAEDs();
        $transformedAEDs = $this->respondWithCollection($aeds, new AEDTransformer);

        // If no aeds are found return with error
        if(!$aeds) {
            $this->setStatusCode(404)->respondWithError("Keine AED in der Datenbank");
        }

        // Add meta information and merge the arrays
        $meta = ['meta' => ['Heading 1' => 'H1', 'Heading 2' => 'H2']];
        $response = array_merge($transformedAEDs, $meta);

        return $this->setStatusCode(200)->respond($response);
    } else {
        $aeds = $this->searchAEDInRange($latitude, $longitude);
        $transformedAEDs = $this->respondWithCollection($aeds, new AEDTransformer);

        if (sizeof($aeds) == 0) {
            $this->setStatusCode(404)->respondWithError("Keine AED in der Datenbank");
        }
    }

    // Set Meta information and combine with data
    $meta = ['meta' => ['Heading 1' => 'H1', 'Heading 2' => 'H2']];
    $result = array_merge($transformedAEDs, $meta);

    return $this->setStatusCode(200)->respond($result);
}
public function index(Request $request) {

    // Get Latitude and Longitude from request url
    $latitude = $request["latitude"];
    $longitude = $request["longitude"];
    $aeds = new AED();

    // In no latitude and longitude is provided in request, search for all aeds
    // If latitude and longitude is set in request, search for aeds in proximity of this location information
    if(!isset($latitude) & !isset($longitude)) {
        $aeds = $aeds->getAllAEDs();
        $transformedAEDs = $this->respondWithCollection($aeds, new AEDTransformer);

        // If no aeds are found return with error
        if(!$aeds) {
            $this->setStatusCode(404)->respondWithError("Keine AED in der Datenbank");
        }

        // Add meta information and merge the arrays
        $meta = ['meta' => ['Heading 1' => 'H1', 'Heading 2' => 'H2']];
        $response = array_merge($transformedAEDs, $meta);

        return $this->setStatusCode(200)->respond($response);
    } else {
        $aeds = $this->searchAEDInRange($latitude, $longitude);
        $transformedAEDs = $this->respondWithCollection($aeds, new AEDTransformer);

        if (sizeof($aeds) == 0) {
            $this->setStatusCode(404)->respondWithError("Keine AED in der Datenbank");
        }
    }

    // Set Meta information and combine with data
    $meta = ['meta' => ['Heading 1' => 'H1', 'Heading 2' => 'H2']];
    $result = array_merge($transformedAEDs, $meta);

    return $this->setStatusCode(200)->respond($result);
}