My API is called twice

Viewed 902

I'm using laravel 5.2, I have a problem with my cURL request, the API is called twice.

I tried to execute the same code on a single .php file without laravel and everything is ok.

I see on the web that may come from the mod_rewrite rules because of parameters but I don't know how check that.

My function look like this :

$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'];

Httacces :

<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>
0 Answers
Related