Cookies?

52 views
Skip to first unread message

Andy Wallace

unread,
Nov 30, 2021, 1:57:01 PM11/30/21
to PHRETS
I am trying to make a connection to the Covington Association of Reators via PHRETS. I can do it with this curl command line:

curl  -k --user 'MYUSERNAME:MYPASSWORD' --cookie-jar 'cookies.txt' --cookie 'cookies.txt' --connect-timeout 60 --max-time 30 --junk-session-cookies --output 'login.debug' 'https://caor-rets.paragonrels.com/rets/fnisrets.aspx/CAOR/login?rets-version=rets/1.7.2'

But PHRETS gets an authorization failure.

    $this->rets_config = new \PHRETS\Configuration;
    ->setUsername( MYUSERNAME )
    ->setPassword( MYPASSWORD )
    ->setRetsVersion( '1.7.2' );

    $this->rets_session = new \PHRETS\Session( $this->rets_config );

    $connect = $this->rets_session->Login();

    This last line throws an exception "resulted in a `401 Unauthorized` response"

My suspicion is that the cookies have something to do with it. I can't figure out how to convert the curl cookie directives into something that PHRETS understands: 
    --cookie-jar 'cookies.txt' 
    --cookie 'cookies.txt'
    --junk-session-cookies

Any ideas? 
Thanks,
Andy

    


Andy Wallace

unread,
Nov 30, 2021, 2:09:52 PM11/30/21
to PHRETS
One note: I tried adding this to the session:

        $this->rets_session->getClient()->setDefaultOption('config', [
            'curl' => [
                CURLOPT_COOKIESESSION => true,
                CURLOPT_COOKIE        => 'cookies.txt',
                CURLOPT_COOKIEJAR     => 'cookies.txt',
            ]
        ]);

And I get a new error:

      cURL error 6: Could not resolve host: config (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)]

Which doesn't really make any sense to me.
Reply all
Reply to author
Forward
0 new messages