Search code examples
phpcurlfilemakererror-code

Filemaker api retruns 958 error code in php


I am trying to access FileMaker by using curl PHP. here I am not using filmmaker PHP class. I am importing the records from the filmmaker into the Prestashop site. when admin delete the product in the Prestashop its also deleted in the FileMaker database

    $nome = 'http://ipaddress:port/fmi/xml/FMPXMLRESULT.xml?-db=tablename&-lay=export&recordid=$recordid&-delete';

    $cURL = curl_init($nome);

    curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($cURL, CURLOPT_FAILONERROR, true);

    curl_setopt($cURL, CURLOPT_HTTPHEADER, $header_fields);

    $response = curl_exec($cURL);

   if ($cURL_err = curl_errno($cURL)) {
    die(__FILE__ . "(" . __LINE__ . "): Communication Error: (' . $cURL_err . ')" . 
    curl_error($cURL));
   }

   curl_close($cURL);

    //Removed the Headers.
   when I am executing the code filmmaker return error code 958.

Solution

  • after some analyze. if we want edit,delete,update the record in the filemaker.we must use the -recid. i made mistake on API

    $nome = 'http://ipaddress:port/fmi/xml/FMPXMLRESULT.xml?-db=tablename&-lay=export&recordid=$recordid&-delete';
    

    it should be

    $nome = 'http://ipaddress:port/fmi/xml/FMPXMLRESULT.xml?-db=database&-lay=export&-recid=$recordid&-delete';
    

    after changed its working correctly.Here I attached some example API for getting records and update the records.

    GET all records

    http://ip_address:port/fmi/xml/FMPXMLRESULT.xml?-db=database&-lay=layout&-findall
    

    Get range of records

    http://ip_address:port/fmi/xml/FMPXMLRESULT.xml?-db=Magazzino&-lay=export&-max=100&-findall
    

    Get specific Record

    http://ip_address:port/fmi/xml/FMPXMLRESULT.xml?-db=database&-lay=export&fieldname=field_value&-find
    

    Insert New

    http://ip_address:port/fmi/xml/FMPXMLRESULT.xml?-db=database&-lay=export&fieldname=field_value&-new
    

    edit record

    http://ip_address:port/fmi/xml/FMPXMLRESULT.xml?-db=database&-lay=export&-recid=record_id&-edit
    

    NOTE: Two way to access filmmaker database 1.using FileMaker class.2.using API