Php 我的API被调用了两次

Php 我的API被调用了两次,php,laravel,mod-rewrite,curl,Php,Laravel,Mod Rewrite,Curl,我使用的是Laravel5.2,我的cURL请求有问题,API调用了两次 我尝试在没有laravel的单个.php文件上执行相同的代码,一切正常 我在网上看到,由于参数的原因,可能来自修改规则,但我不知道如何检查 我的函数如下所示: $url = 'http://api.com/api.asmx/deepSearchCreate'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOP

我使用的是
Laravel5.2
,我的cURL请求有问题,API调用了两次

我尝试在没有laravel的单个.php文件上执行相同的代码,一切正常

我在网上看到,由于参数的原因,可能来自修改规则,但我不知道如何检查

我的函数如下所示:

$url = 'http://api.com/api.asmx/deepSearchCreate';
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'apikey=API_KEY&search='.strip_tags(trim($article->contenu)).'&source=&searchid=');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json, TRUE);

$id = $array['collection']['@attributes']['id'];
<IfModule mod_headers.c>
    <FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>
</IfModule>

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Deny access to framework directories
    RewriteRule ^(app/|bootstrap/|config/|database/|resources/|storage/tests|vendor/) - [R=404,L,NC]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # And dot files/folders (for example .env)
    RedirectMatch 404 /\..*$

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Httacces:

$url = 'http://api.com/api.asmx/deepSearchCreate';
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'apikey=API_KEY&search='.strip_tags(trim($article->contenu)).'&source=&searchid=');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json, TRUE);

$id = $array['collection']['@attributes']['id'];
<IfModule mod_headers.c>
    <FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>
</IfModule>

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Deny access to framework directories
    RewriteRule ^(app/|bootstrap/|config/|database/|resources/|storage/tests|vendor/) - [R=404,L,NC]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # And dot files/folders (for example .env)
    RedirectMatch 404 /\..*$

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

标题集访问控制允许原点“*”
选项-多视图
重新启动发动机
#拒绝访问框架目录
重写规则^(应用程序/|引导程序/|配置/|数据库/|资源/|存储/测试|供应商/)-[R=404,L,NC]
#如果不是文件夹,则重定向尾部斜杠。。。
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)/$/$1[L,R=301]
#和点文件/文件夹(例如.env)
重定向匹配404/\*$
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]

@Robert你确定吗?我该怎么解决呢?这是讽刺,如果我是你,我会通过debbuger,看看会发生什么。你也可以使用“退出”或“死亡”,然后看看它是否被调用once@Robert我试着写一个文件,一切都很好,没有重复。我认为问题在于curl中的参数,或者您请求的文件中有bug,比如@Robert said,您需要更好地调试。它是如何执行的?通过控制台还是在浏览器中打开正确的url?