Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. [Frage] HTTP POST - Cookie einfügen ? (Sony TV)

NEWS

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    18
    1
    744

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    18
    1
    6.0k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.5k

[Frage] HTTP POST - Cookie einfügen ? (Sony TV)

Scheduled Pinned Locked Moved Skripten / Logik
5 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lucky
    wrote on last edited by
    #1

    MOD-Edit by eric2905; 03.05.2017/09:55; Betreff angepasst

    Hallo,

    ich möchte meinen Sony Bravia TV mit ioBroker steuern, der syntax und die vorgehensweise sind mir bekannt.

    Der TV möchte JSON Strings per HTTP POST haben, bevor er aber eine Steuerung zulässt muß man sich als "Fernbedienung" Registrieren, lesen geht auch ohne Registrierung

    die Vorgehensweise zur Registrierung ist wie folgt:

    1. POST an http://192.168.xxx.xxx/sony/accessControl mit JSON String:

    {"id":13,"method":"actRegister","version":"1.0","params":[{"clientid":"ioBroker:1","nickname":"ioBroker"},[{"clientid":"ioBroker:1","value":"yes","nickname":"ioBroker","function":"WOL"}]]}

    2. TV zeigt darauf hin eine Meldung mit PIN

    3. PIN in base64 codieren und im Header mit 'Authorization':'Basic Ojg2MzA=' zurück schicken

    4. TV Sendet darauf hin ein Cookie z.b. auth=eefbfe6c3bdab6b7876c560cbe292ddb82f425bca256b226d487w03b39fc6a5b <- bis hier hin alles ok, und läuft

    5. das Cookie muß jetzt für jeden weitern POST Request mit gesendet werden

    jetzt das Problem: wie sende ich das coockie ? ich denke es muß im Header definiert werden ?!

    meine Code bis jetz:

    var request = require('request');
    
    // Configure the request
    var options = {
        url: 'http://192.168.188.24/sony/system',
        //url: 'http://192.168.188.24/sony/accessControl',
        method: 'POST',
        headers: {
        'Authorization':'Basic Ojg2MzA=',
        },
    
        form: '{"method": "setPowerStatus","params": [{"status": false}],"id": 102}' 
        //form:' {"id":13,"method":"actRegister","version":"1.0","params":[{"clientid":"ioBroker:1","nickname":"ioBroker"},[{"clientid":"ioBroker:1","value":"yes","nickname":"ioBroker","function":"WOL"}]]}'
    };
    
    // Start the request
    request(options, function (error, response, body) {
        if (!error && response.statusCode == 200) {
            // Print out the response body
            //console.log(body);
        }
    
        console.log('Response:' + JSON.stringify(response));
        console.log('Error: ' + error);
        console.log('Body: '+ body);
    
    });
    
    1 Reply Last reply
    0
    • AlCalzoneA Offline
      AlCalzoneA Offline
      AlCalzone
      Developer
      wrote on last edited by
      #2

      Schau mal hier: https://github.com/request/request

      fast ganz unten

      > Cookies are disabled by default (else, they would be used in subsequent requests). To enable cookies, set jar to true (either in defaults or options).

      Da sind auch Beispiele für kompliziertere Fälle, wie das Einfügen eines eigenen Cookies:

      var j = request.jar();
      var cookie = request.cookie('key1=value1');
      var url = 'http://www.google.com';
      j.setCookie(cookie, url);
      request({url: url, jar: j}, function () {
        request('http://images.google.com')
      })
      

      Warum `sudo` böse ist: https://forum.iobroker.net/post/17109

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Lucky
        wrote on last edited by
        #3

        ok, das erklärt schon mal etwas..

        allerdings stehe ich trotzdem gerade aufm Schlauch :-/ wo muss ich entsprechend in meinem Code anpassungen machen ? alles was ich bis jetzt versucht habe, hat leider nicht funktioniert

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Lucky
          wrote on last edited by
          #4

          hat sich erledigt, klappt jetzt :-)

          hier die Lösung

          var request = require('request');
          var url='http://192.168.188.24/sony/system';
          //url: 'http://192.168.188.24/sony/accessControl',
          
          PIN=Buffer.from(':'+'0396');
          
          // Configure the request
          var options = {
              url: url,
              jar: true,
              method: 'POST',
              headers: {'Authorization':'Basic '+ PIN.toString('base64')},
              form: '{"method": "setPowerStatus","params": [{"status": false}],"id": 102}' 
              //form:' {"id":13,"method":"actRegister","version":"1.0","params":[{"clientid":"ioBroker:1","nickname":"ioBroker"},[{"clientid":"ioBroker:1","value":"yes","nickname":"ioBroker","function":"WOL"}]]}'
          };
          
          var j = request.jar();
          var cookie = request.cookie('auth=a63b94235f935cc102ef679eca03081b217b0df10c641099c90d02f8c651d0fe');
          
          // Start the request
          
          j.setCookie(cookie,url);
          request(options, function (error, response, body) {
          
              console.log('Response:' + JSON.stringify(response));
              console.log('Error: ' + error);
              console.log('Body: '+ body);
          
          });
          
          1 Reply Last reply
          0
          • AlCalzoneA Offline
            AlCalzoneA Offline
            AlCalzone
            Developer
            wrote on last edited by
            #5

            Wenn ich das richtig sehe, solltest du die manuelle Cookie-Zuweisung nicht brauchen, wenn du beim initialen Request jar:true festlegst. Aber wenns funktioniert, ist das schon mal was.

            Warum `sudo` böse ist: https://forum.iobroker.net/post/17109

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            Support us

            ioBroker
            Community Adapters
            Donate

            606

            Online

            32.8k

            Users

            82.7k

            Topics

            1.3m

            Posts
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
            ioBroker Community 2014-2025
            logo
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Home
            • Recent
            • Tags
            • Unread 0
            • Categories
            • Unreplied
            • Popular
            • GitHub
            • Docu
            • Hilfe