api login doesn't work

Hi to all, i’ve developed my script to import accounts on database, on local it works fine, but when i put online the result of the login is everyitime false, i really don’t understand why:

?php
$job_strings[] = 'importData';



//$url = "http://crmdemo.lifeyourbrand.it/service/v4_1_custom/rest.php ";
$url = "http://crm.delbarbaconsulting.com/service/v4_1/rest.php";

function restRequest($method, $arguments,$url){

    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $post = array(
        "method" => $method,
        "input_type" => "JSON",
        "response_type" => "JSON",
        "rest_data"=>json_encode($arguments),

    );

    curl_setopt($curl, CURLOPT_POSTFIELDS, $post);

    $result = curl_exec($curl);

    curl_close($curl);
    var_dump(json_encode($post));
    var_dump(json_encode($arguments));
    var_dump(json_encode($result));
    
   // var_dump(json_encode($result));
//	 die();
//echo "******************************************************";
    return json_decode($result,1);
}


$userAuth = array(
    'user_name' => 'xxxxxxxxx',
    'password' => md5('xxxxxxxxxxxxxxx'),
);
$appName = 'My SuiteCRM REST Client';
$nameValueList = array();

$args =array(
    'user_auth' => $userAuth,
//     'application_name' => $appName,
//     'name_value_list' => $nameValueList
);
$result = restRequest('login',$args,$url);
$sessId=$result['id'];

echo $sessId;

?>

the result is:
string(175) “{“method”:“login”,“input_type”:“JSON”,“response_type”:“JSON”,“rest_data”:”{“user_auth”:{“user_name”:“xxxxxxxxxxx”,“password”:“xxxxxxxxxxxxxxxxxxxxxxx”}}"}" string(89) “{“user_auth”:{“user_name”:“xxxxxxxxxxx”,“password”:“xxxxxxxxxxxxxxxxxxxxxxx”}}” string(5) “false”

any suggest?

Check the server logs for errors.

where i could find this logs?

Google would tell you that faster than me, but here you go

https://pgorod.github.io/The-two-logs/

1 Like

I found the problem, actually i was calling the server in the server itself, and without configuring the hosts it give me a 404, now it works