Web services 使用curl_setopt($ch,CURLOPT_POSTFIELDS,$data)发送数据时发生Laravel-4 notfoundhttpexception

Web services 使用curl_setopt($ch,CURLOPT_POSTFIELDS,$data)发送数据时发生Laravel-4 notfoundhttpexception,web-services,rest,laravel-4,Web Services,Rest,Laravel 4,当我以curl格式发送数据时,我得到了notfoundhttpexception,其中包含以下详细信息 Server/Request Data REDIRECT_STATUS 200 HTTP_HOST localhost:81 HTTP_ACCEPT */* CONTENT_LENGTH 15 CONTENT_TYPE application/x-www-form-urlencoded SystemRoot C:\windows COMSPEC C:\wi

当我以curl格式发送数据时,我得到了
notfoundhttpexception
,其中包含以下详细信息

Server/Request Data
REDIRECT_STATUS     200
HTTP_HOST   localhost:81
HTTP_ACCEPT     */*
CONTENT_LENGTH  15
CONTENT_TYPE    application/x-www-form-urlencoded
SystemRoot  C:\windows
COMSPEC     C:\windows\system32\cmd.exe
PATHEXT     .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
WINDIR  C:\windows
SERVER_SIGNATURE    
SERVER_SOFTWARE     Apache/2.4.4 (Win32) PHP/5.4.16
SERVER_NAME     localhost
SERVER_ADDR     ::1
SERVER_PORT     81
REMOTE_ADDR     ::1
DOCUMENT_ROOT   D:/wamp/www
REQUEST_SCHEME  http
CONTEXT_PREFIX  
CONTEXT_DOCUMENT_ROOT   D:/wamp/www
SERVER_ADMIN    admin@example.com
SCRIPT_FILENAME     D:/wamp/www/HRMS/public/index.php
REMOTE_PORT     61767
REDIRECT_URL    /HRMS/public/services/test
GATEWAY_INTERFACE   CGI/1.1
SERVER_PROTOCOL     HTTP/1.1
REQUEST_METHOD  POST
QUERY_STRING    
REQUEST_URI     /HRMS/public/services/test
SCRIPT_NAME     /HRMS/public/index.php
PHP_SELF    /HRMS/public/index.php
REQUEST_TIME_FLOAT  1400157353.813
REQUEST_TIME    1400157353
下面是代码:

public function getData() {
    $data=http_build_query(array("purpose"=>"Testing"));

    $url = "http://localhost:81/HRMS/public/services/test";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_URL,$url); 
    curl_setopt($ch, CURLOPT_HEADER,false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    $result = curl_exec($ch);

    return View::make("userlogin")->with("result",$result);
}


public function test() {

    $jsonData = array("Purpose" => "Testing Web Service", "Web Service" => "REST", "Status" => "Success");

    $input = file_get_contents('php://input');

    if ( $input ) {
    $response = Response::make($jsonData, 200);
    $response->header('Content-Type', "application/json");
    }else{
    $data = array("input" => "Not Testing");
    $response = Response::make($data, 200);
    $response->header('Content-Type', "application/json");
    }
    return $response;
    $input = file_get_contents('php://input');
    return "$input TEST Work";

}
但是,当我发送数据删除post字段“CURLOPT_POSTFIELDS”时,它工作正常。当我包含“CURLOPT_POSTFIELDS”时,它抛出了
notfoundhttp
exception


这个问题的原因是什么?请引导。

您可以将路线更改为
post
,因为您正在将curl请求设置为HTTP post

Route::post(...);

你的路线是什么样子的?路线::获取,在将其更改为路线::任何有效的路线后。。。