Navigation

    Home
    All Categories
    • KEEN Trail Camera
    • Top #ReolinkCaptures Awards
    • Announcements and News
    • Wishlist
    • #ReolinkTrial
    • Discussion About Products
    • Reolink Captures
    • Reolink Client & APP
    #ReolinkTrial
    Reolink Captures
    Log in to post
    Guest
    • Guest
    • Register
    • Login

    Learn More

    Reolink updates Learn More

    Meet Reolink at IFA 2024! Learn More

    Reolink Q&A Learn More

    API call "Search" returns "please login first"

    Reolink Client & APP
    2
    7
    1004
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • user_686576360607949_686576360607949
      user_686576360607949 last edited by

      I am trying to implement the "search" call in PHP.
      My quick hack code is:

      <?php
              // Login ==============================
              $ch = curl_init();
              curl_setopt($ch, CURLOPT_POSTFIELDS,     '[{"cmd":"Login","param":{"User":{"userName":"admin","password":"password"}}}]' );
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              curl_setopt($ch, CURLOPT_URL, "http://192.168.1.1/cgi-bin/api.cgi?cmd=Login");
              $output = curl_exec($ch);
              $jsonobj = substr($output,1,-2);
              $obj = json_decode($jsonobj);
              echo "Token: ".$obj->value->Token->name."<br>";
              $tokenName = $obj->value->Token->name;
              // Login ==============================
              
              $toSearch = '[{ "cmd": "Search", "action":0, "param": { "Search": { "channel": 0, "onlyStatus": 1, "streamType": "main", "StartTime": { "year": 2023, "mon": 04, "day": 21, "hour": 12, "min": 26, "sec": 1  }, "EndTime": { "year": 2023, "mon": 04, "day": 24, "hour": 12, "min": 34, "sec": 1 }]';
              $ch = curl_init();
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              curl_setopt($ch, CURLOPT_URL, "http://192.168.1.1/api.cgi?cmd=Search&token=".$tokenName);
              curl_setopt($ch, CURLOPT_POSTFIELDS,  $toSearch );
              $output = curl_exec($ch);
              echo $output;
      ?>

      Response is:

      Token: 423e78c93350582
      [ { "cmd" : "Search", "code" : 1, "error" : { "detail" : "please login first", "rspCode" : -6 } } ]

      Other calls seem to work fine.
      Any Ideas?
      Cam is a Reolink TrackMix WiFi with latest firmware.

      Reply Quote
      Share
      • Share this Post
      • Facebook
      • Twitter
      • copy the link
        Copied!
      0
        • joseph_1979
          Joseph Global Moderator @user_686576360607949 last edited by joseph_1979

          @user_686576360607949_686576360607949 Enable HTTPS from Network menu and run the following curl command. Just replace the CameraIP with the private IP of the camera.

          curl -s -k -X POST -H "Content-Type : application/json" -d "[{"cmd": "Search", "action":0, "param": { "Search": { "channel": 0, "onlyStatus": 1, "streamType": "main", "StartTime": { "year": 2023, "mon": 04, "day": 21, "hour": 12, "min": 26, "sec": 1},"EndTime": { "year": 2023,"mon": 04, "day": 21, "hour": 21, "min": 34, "sec": 1}}}}]" "https://CameraIP/cgi-bin/api.cgi?user=#username#&password=#password#"

          Reply Quote
          Share
          • Share this Post
          • Facebook
          • Twitter
          • copy the link
            Copied!
          0
          • user_686576360607949_686576360607949
            user_686576360607949 @Joseph last edited by

            @joseph-chircop_497308027822318 so do you think using a token is not supported? It is described in the API spec, though.

            Reply Quote
            Share
            • Share this Post
            • Facebook
            • Twitter
            • copy the link
              Copied!
            0
            View 4 replies
          • First post
            Last post
          All Categories
          Announcements and News Reolink Client & APP Discussion About Products #ReolinkTrial Reolink Captures Wishlist KEEN Trail Camera
          Never miss Reolink hot deals, news, and updates tailored for you.

          Thanks for your subscription!

          Please enter a valid email address.

          Oops… Something went wrong. Please try again later.

          You are already subscribed to this email list. :)

          Submission failed. Please try again later.

          Reolink Store|Support|About Us|Privacy Policy|Terms and Conditions

          Copyright 2025 © Reolink All Rights Reserved.

          Welcome Back!

          Hi there! Join the Commnunity to get all the latest news, tips and more!

          Join Now