Not able to login in SuiteCRM through REST API

2019-09-02 10:31发布

I am trying to login to SuiteCRM using REST API. Used the same code which was shown in demo SuiteCRM rest API document. The code is working fine on localhost. But when I am putting the file in server. It is showing a blank screen.

<?php

$url = "http://example.com/suitecrm/service/v4_1/rest.php";

function restRequest($method, $arguments){
 global $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);
 return json_decode($result,1);
}


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

$args = array(
            'user_auth' => $userAuth,
            'application_name' => $appName,
            'name_value_list' => $nameValueList);

$result = restRequest('login',$args);
$sessId = $result['id'];
echo $sessId;

The same code is working when I am using the link of demo.suiteondemand.com and passing its username and password. Can it be a problem of http and https?

0条回答
登录 后发表回答