Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Bones: "The man's DEAD, Jim!"


devel / comp.lang.xharbour / sending token via REST API

SubjectAuthor
* sending token via REST APIoksana -
`* Re: sending token via REST APIDan
 `* Re: sending token via REST APIoksana -
  `* Re: sending token via REST APIDan
   +- Re: sending token via REST APIoksana -
   `* Re: sending token via REST APIoksana -
    `* Re: sending token via REST APIDan
     `- Re: sending token via REST APIoksana -

1
sending token via REST API

<342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16798&group=comp.lang.xharbour#16798

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:620a:2544:: with SMTP id s4mr2860821qko.219.1634185861982;
Wed, 13 Oct 2021 21:31:01 -0700 (PDT)
X-Received: by 2002:a37:9642:: with SMTP id y63mr2781588qkd.14.1634185861809;
Wed, 13 Oct 2021 21:31:01 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Wed, 13 Oct 2021 21:31:01 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=110.139.244.11; posting-account=HN9wBgoAAAAGn0kNV7rbBTnXMb6oGMw4
NNTP-Posting-Host: 110.139.244.11
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com>
Subject: sending token via REST API
From: oksa10203040@gmail.com (oksana -)
Injection-Date: Thu, 14 Oct 2021 04:31:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 96
 by: oksana - - Thu, 14 Oct 2021 04:31 UTC

Hello,

I'm working on converting from php to harbor,
i.e. by sending token via REST API.

After I compiled the PRG file, the results did not come out and stopped at the message "test out-1",
even though in the PHP script it worked.

Can anyone help me to get output for the PRG above ?
thanks

regards
Oksa

PHP ============================================
<?php
//2021-10-14 works!!
$personalToken = "f9v9wwFnusSWbAdt7Yivg58BDeCKm76s";
$url = "https://api.envato.com/v1/market/user:OksaSaja.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".$personalToken));
$response = @curl_exec($ch);
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if (curl_errno($ch) > 0) {
throw new Exception("Failed to connect: " . curl_error($ch));
}

switch ($responseCode) {
case 403: throw new Exception("The personal token is missing the required permission for this script");
case 401: throw new Exception("The personal token is invalid or has been deleted");
}

if ($responseCode !== 200) {
throw new Exception("Got status {$responseCode}, try again shortly");
}

print_r($response);
$body = @json_decode($response);

if ($body === false && json_last_error() !== JSON_ERROR_NONE) {
throw new Exception("Error parsing response, try again");
}

print_r($body);
?>

PRG======================================================
#include "hmg.ch"

Function main
Local cAuth := "f9v9wwFnusSWbAdt7Yivg58BDeCKm76s"
Local cUrl := "https://api.envato.com/v1/market/user:OksaSaja.json"
Local nTimeOut := 20 // seconds
Local oRestApi
Local cReturn, cResponse

oRestApi := Win_OleCreateObject( "MSXML2.ServerXMLHTTP" )
oRestApi:setTimeouts(nTimeout * 1000 /* nResolve */ , nTimeout * 1000 /* nConnect*/ , nTimeout * 1000 /* nSend */, nTimeout * 1000 /* nReceive */ )

If Empty( oRestApi )
? "Error al inicializar..."
Return NIL
Endif

BEGIN SEQUENCE WITH { |o| Break(o) }

oRestApi:Open( "POST", cUrl, .F. )
oRestApi:setRequestHeader( "Content-Type", "application/json" )
oRestApi:setRequestHeader( "Accept", "application/json" )

oRestApi:setRequestHeader( "Authorization: Bearer ", cAuth ) // <<--- maybe error here...
MSGINFO('test out-1')
oRestApi:Send( '' ) // <<--- error here...

MSGINFO('test out-2')
? cReturn := hb_jsonDecode( oRestApi:ResponseText() )

? hb_jsonDecode( oRestApi:ResponseBody() )

RECOVER USING oErr
MSGINFO('test out-3')
cReturn := "Error!" + hb_eol() + If ( ValType( oErr ) = 'O', oErr:Description, oErr )
END SEQUENCE

oRestApi := NIL

Return
=================================================

Re: sending token via REST API

<sk8ego$364$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16799&group=comp.lang.xharbour#16799

  copy link   Newsgroups: comp.lang.xharbour
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: webmaster@appliserver.com (Dan)
Newsgroups: comp.lang.xharbour
Subject: Re: sending token via REST API
Date: Thu, 14 Oct 2021 07:17:10 +0200
Organization: A noiseless patient Spider
Lines: 101
Message-ID: <sk8ego$364$1@dont-email.me>
References: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 14 Oct 2021 05:17:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9fea90f8411df574f6363f548c2ba74c";
logging-data="3268"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ll+qmvcEdChEmci6l5MSm"
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:YVCJ5ZtdsbpXY6uJxl3fhKRfXMc=
In-Reply-To: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com>
Content-Language: it
 by: Dan - Thu, 14 Oct 2021 05:17 UTC

Il 14/10/2021 06:31, oksana - ha scritto:
> Hello,
>
> I'm working on converting from php to harbor,
> i.e. by sending token via REST API.
>
> After I compiled the PRG file, the results did not come out and stopped at the message "test out-1",
> even though in the PHP script it worked.
>
> Can anyone help me to get output for the PRG above ?
> thanks
>
> regards
> Oksa
>
> PHP ============================================
> <?php
> //2021-10-14 works!!
>
> $personalToken = "f9v9wwFnusSWbAdt7Yivg58BDeCKm76s";
> $url = "https://api.envato.com/v1/market/user:OksaSaja.json";
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, $url);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".$personalToken));
>
> $response = @curl_exec($ch);
> $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
>
> if (curl_errno($ch) > 0) {
> throw new Exception("Failed to connect: " . curl_error($ch));
> }
>
> switch ($responseCode) {
> case 403: throw new Exception("The personal token is missing the required permission for this script");
> case 401: throw new Exception("The personal token is invalid or has been deleted");
> }
>
> if ($responseCode !== 200) {
> throw new Exception("Got status {$responseCode}, try again shortly");
> }
>
> print_r($response);
> $body = @json_decode($response);
>
>
> if ($body === false && json_last_error() !== JSON_ERROR_NONE) {
> throw new Exception("Error parsing response, try again");
> }
>
> print_r($body);
> ?>
>
> PRG======================================================
> #include "hmg.ch"
>
> Function main
> Local cAuth := "f9v9wwFnusSWbAdt7Yivg58BDeCKm76s"
> Local cUrl := "https://api.envato.com/v1/market/user:OksaSaja.json"
> Local nTimeOut := 20 // seconds
> Local oRestApi
> Local cReturn, cResponse
>
> oRestApi := Win_OleCreateObject( "MSXML2.ServerXMLHTTP" )
> oRestApi:setTimeouts(nTimeout * 1000 /* nResolve */ , nTimeout * 1000 /* nConnect*/ , nTimeout * 1000 /* nSend */, nTimeout * 1000 /* nReceive */ )
>
> If Empty( oRestApi )
> ? "Error al inicializar..."
> Return NIL
> Endif
>
> BEGIN SEQUENCE WITH { |o| Break(o) }
>
> oRestApi:Open( "POST", cUrl, .F. )
> oRestApi:setRequestHeader( "Content-Type", "application/json" )
> oRestApi:setRequestHeader( "Accept", "application/json" )
>
> oRestApi:setRequestHeader( "Authorization: Bearer ", cAuth ) // <<--- maybe error here...
>
> MSGINFO('test out-1')
> oRestApi:Send( '' ) // <<--- error here...
>
> MSGINFO('test out-2')
> ? cReturn := hb_jsonDecode( oRestApi:ResponseText() )
>
> ? hb_jsonDecode( oRestApi:ResponseBody() )
>
> RECOVER USING oErr
> MSGINFO('test out-3')
> cReturn := "Error!" + hb_eol() + If ( ValType( oErr ) = 'O', oErr:Description, oErr )
>
> END SEQUENCE
>
> oRestApi := NIL
>
> Return
> =================================================
>
At a first glance: what is Oerr?
Dan

Re: sending token via REST API

<7e64c9ba-4a67-4eb5-82e8-b73d10ece965n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16800&group=comp.lang.xharbour#16800

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:6214:50c:: with SMTP id v12mr3399595qvw.45.1634193248536;
Wed, 13 Oct 2021 23:34:08 -0700 (PDT)
X-Received: by 2002:ac8:1e95:: with SMTP id c21mr4547099qtm.412.1634193248401;
Wed, 13 Oct 2021 23:34:08 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Wed, 13 Oct 2021 23:34:08 -0700 (PDT)
In-Reply-To: <sk8ego$364$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=110.139.244.11; posting-account=HN9wBgoAAAAGn0kNV7rbBTnXMb6oGMw4
NNTP-Posting-Host: 110.139.244.11
References: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com> <sk8ego$364$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7e64c9ba-4a67-4eb5-82e8-b73d10ece965n@googlegroups.com>
Subject: Re: sending token via REST API
From: oksa10203040@gmail.com (oksana -)
Injection-Date: Thu, 14 Oct 2021 06:34:08 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 5
 by: oksana - - Thu, 14 Oct 2021 06:34 UTC

oErr it is an error object.
The PRG file does not fail at compille, but produces no output. Whereas for the example PHP file it can produce output.

regards
oksa

Re: sending token via REST API

<sk8jcj$q7d$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16801&group=comp.lang.xharbour#16801

  copy link   Newsgroups: comp.lang.xharbour
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: webmaster@appliserver.com (Dan)
Newsgroups: comp.lang.xharbour
Subject: Re: sending token via REST API
Date: Thu, 14 Oct 2021 08:40:16 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <sk8jcj$q7d$1@dont-email.me>
References: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com>
<sk8ego$364$1@dont-email.me>
<7e64c9ba-4a67-4eb5-82e8-b73d10ece965n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 14 Oct 2021 06:40:19 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9fea90f8411df574f6363f548c2ba74c";
logging-data="26861"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18w30FeMXwiGZz3xXsR/p8X"
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:GPQ23ThUklQBJeGAArJNoxnoPeo=
In-Reply-To: <7e64c9ba-4a67-4eb5-82e8-b73d10ece965n@googlegroups.com>
Content-Language: it
 by: Dan - Thu, 14 Oct 2021 06:40 UTC

Il 14/10/2021 08:34, oksana - ha scritto:
> oErr it is an error object.
>
> The PRG file does not fail at compille, but produces no output. Whereas for the example PHP file it can produce output.
>
> regards
> oksa
>
I mean, you define o and call oErr.
Dan

Re: sending token via REST API

<73f735b9-33a4-4436-a153-2d8111a30eden@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16802&group=comp.lang.xharbour#16802

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:6214:a10:: with SMTP id dw16mr5688071qvb.57.1634220063537; Thu, 14 Oct 2021 07:01:03 -0700 (PDT)
X-Received: by 2002:ad4:4366:: with SMTP id u6mr5615328qvt.36.1634220063398; Thu, 14 Oct 2021 07:01:03 -0700 (PDT)
Path: rocksolid2!news.neodome.net!news.nntp4.net!aioe.org!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Thu, 14 Oct 2021 07:01:03 -0700 (PDT)
In-Reply-To: <sk8jcj$q7d$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=110.139.244.11; posting-account=HN9wBgoAAAAGn0kNV7rbBTnXMb6oGMw4
NNTP-Posting-Host: 110.139.244.11
References: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com> <sk8ego$364$1@dont-email.me> <7e64c9ba-4a67-4eb5-82e8-b73d10ece965n@googlegroups.com> <sk8jcj$q7d$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <73f735b9-33a4-4436-a153-2d8111a30eden@googlegroups.com>
Subject: Re: sending token via REST API
From: oksa10203040@gmail.com (oksana -)
Injection-Date: Thu, 14 Oct 2021 14:01:03 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 12
 by: oksana - - Thu, 14 Oct 2021 14:01 UTC

u can use script

RECOVER

MsgStop("ERROR! ")
RETURN
END SEQUENCE

i don't understand about oErr but i want my PRG run very well and the result
> >
> I mean, you define o and call oErr.
> Dan

Re: sending token via REST API

<1e1121a4-c3c5-4756-93f0-6df136ef8c60n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16803&group=comp.lang.xharbour#16803

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:622a:1754:: with SMTP id l20mr6889227qtk.309.1634220384372;
Thu, 14 Oct 2021 07:06:24 -0700 (PDT)
X-Received: by 2002:a05:622a:341:: with SMTP id r1mr1134230qtw.354.1634220384251;
Thu, 14 Oct 2021 07:06:24 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Thu, 14 Oct 2021 07:06:24 -0700 (PDT)
In-Reply-To: <sk8jcj$q7d$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=110.139.244.11; posting-account=HN9wBgoAAAAGn0kNV7rbBTnXMb6oGMw4
NNTP-Posting-Host: 110.139.244.11
References: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com>
<sk8ego$364$1@dont-email.me> <7e64c9ba-4a67-4eb5-82e8-b73d10ece965n@googlegroups.com>
<sk8jcj$q7d$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e1121a4-c3c5-4756-93f0-6df136ef8c60n@googlegroups.com>
Subject: Re: sending token via REST API
From: oksa10203040@gmail.com (oksana -)
Injection-Date: Thu, 14 Oct 2021 14:06:24 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 19
 by: oksana - - Thu, 14 Oct 2021 14:06 UTC

u can use script

RECOVER

MsgStop("ERROR! ")
RETURN

END SEQUENCE

i don't understand about oErr but i want my PRG run very well like my PHP script.

what is your suggestion?

regards
Oksa

> >
> I mean, you define o and call oErr.
> Dan

Re: sending token via REST API

<sk9m5o$1v6$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16804&group=comp.lang.xharbour#16804

  copy link   Newsgroups: comp.lang.xharbour
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: webmaster@appliserver.com (Dan)
Newsgroups: comp.lang.xharbour
Subject: Re: sending token via REST API
Date: Thu, 14 Oct 2021 18:33:57 +0200
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <sk9m5o$1v6$1@dont-email.me>
References: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com>
<sk8ego$364$1@dont-email.me>
<7e64c9ba-4a67-4eb5-82e8-b73d10ece965n@googlegroups.com>
<sk8jcj$q7d$1@dont-email.me>
<1e1121a4-c3c5-4756-93f0-6df136ef8c60n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 14 Oct 2021 16:34:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9fea90f8411df574f6363f548c2ba74c";
logging-data="2022"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1888qRco+lbjT/oACSyY7VB"
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:CoMTOEoNiDx/BARIsG5+H/NNPLQ=
In-Reply-To: <1e1121a4-c3c5-4756-93f0-6df136ef8c60n@googlegroups.com>
Content-Language: it
 by: Dan - Thu, 14 Oct 2021 16:33 UTC

Il 14/10/2021 16:06, oksana - ha scritto:
> u can use script
>
> RECOVER
>
> MsgStop("ERROR! ")
> RETURN
>
> END SEQUENCE
>
> i don't understand about oErr but i want my PRG run very well like my PHP script.
>
> what is your suggestion?
>
> regards
> Oksa
>
>
>>>
>> I mean, you define o and call oErr.
>> Dan

https://www.access-programmers.co.uk/forums/threads/createobject-msxml2-serverxmlhttp-not-working.312768/

Why not to use curl?
Dan

Re: sending token via REST API

<fd3f60ef-f48a-4afb-93cd-9134295c7bcfn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16806&group=comp.lang.xharbour#16806

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:6214:506:: with SMTP id v6mr8573691qvw.52.1634258429206;
Thu, 14 Oct 2021 17:40:29 -0700 (PDT)
X-Received: by 2002:a05:620a:4042:: with SMTP id i2mr5430704qko.355.1634258429052;
Thu, 14 Oct 2021 17:40:29 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Thu, 14 Oct 2021 17:40:28 -0700 (PDT)
In-Reply-To: <sk9m5o$1v6$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=103.83.93.166; posting-account=HN9wBgoAAAAGn0kNV7rbBTnXMb6oGMw4
NNTP-Posting-Host: 103.83.93.166
References: <342a097e-91f2-4a2c-9479-c305ec5ee757n@googlegroups.com>
<sk8ego$364$1@dont-email.me> <7e64c9ba-4a67-4eb5-82e8-b73d10ece965n@googlegroups.com>
<sk8jcj$q7d$1@dont-email.me> <1e1121a4-c3c5-4756-93f0-6df136ef8c60n@googlegroups.com>
<sk9m5o$1v6$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fd3f60ef-f48a-4afb-93cd-9134295c7bcfn@googlegroups.com>
Subject: Re: sending token via REST API
From: oksa10203040@gmail.com (oksana -)
Injection-Date: Fri, 15 Oct 2021 00:40:29 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 10
 by: oksana - - Fri, 15 Oct 2021 00:40 UTC

> https://www.access-programmers.co.uk/forums/threads/createobject-msxml2-serverxmlhttp-not-working.312768/
>
> Why not to use curl?
> Dan

I've tried it with curl but it doesn't work

maybe you can try it either with MSXML or CURL with the token and urlapi above. Though the token can run in PHP.

regards
oksa

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor