2

Hy everyone.I am new to Mautic.I have installed mautic 2.15.1 on my live Linux sever where SSL is intalled.After that i enabled API by going to settings>Configurations

Now I am facing issue in Mautic APIs response.Actually i want to take information of contact from mautic using Mautic php API.I am using this PHP API https://packagist.org/packages/mautic/api-library .I have setup this as described in the library.

Here is my code to get details of contact using API

    <?php 
    include __DIR__ . '/vendor/autoload.php'; 

    use Mautic\MauticApi;
    use Mautic\Auth\ApiAuth;  

    session_start();
    $settings = array(
        'userName'   => 'username',
        'password'   => 'password'
    );
    $initAuth = new ApiAuth();
    $auth = $initAuth->newAuth($settings, 'BasicAuth');
    $timeout = 10;
    $auth->setCurlTimeout($timeout);
    $api = new MauticApi();
    $contactApi = $api->newApi('contacts', $auth, 'http://my-mautic-server.com/api');
    $response = $contactApi->getList();
    $response = $contactApi->get(23295);
    echo "<pre>";
    print_r($response);

Now i have a user that has ID=>23295 in Mautic and i want to get information of that user.But when i run this code i get this response.Please see Image enter image description here

I have searched this code 0 response but don't get any information in Mautic about this response.Here i want to tell you that i have also test this on localhost.I have installed Mautic 2.15.1 on localhost and then i try same code and my code works and i get the array of specific contact

To Debug this issue on live server i have done following

  1. I have checked php version.My php version is 5.6 on live server
  2. I have checked curl extension is enabled
  3. I have cleared the cache of Mautic by deleting the internal folders in /app/cache directory

I have stuck on this thing from two days.This thing is little strange because this whole process is working on my localhost perfectly but on live server API is returning code 0 response.

Your help will ease my life. Thanks

Shaniawan
  • 243
  • 2
  • 16

0 Answers0