O onair Member Licensed User Longtime User Jul 10, 2018 #1 how to translate from java code to B4J this: Code: Copy httpGet.addHeader("Authorization", "Basic "+Base64.encodeToString("rat#1:rat".getBytes(),Base64.NO_WRAP)); regards
how to translate from java code to B4J this: Code: Copy httpGet.addHeader("Authorization", "Basic "+Base64.encodeToString("rat#1:rat".getBytes(),Base64.NO_WRAP)); regards
DonManfred Expert Licensed User Longtime User Jul 10, 2018 #2 something like Code: Copy Dim Job As HttpJob Job.Initialize("fcm", Me) Job.Download("https://www.google.com") 'Job.GetRequest.SetContentType("application/json;charset=UTF-8") Job.GetRequest.SetHeader("Authorization", "Basic "&Base64.encodeToString("rat#1:rat".getBytes(),Base64.NO_WRAP)) Note that you need to set the header AFTER job.download/poststring... Edit: The base64 you can do with stringutils and Byteconverter. Code: Copy su.EncodeBase64(bc.StringToBytes(USERNAME&":"&PASSWORD,"ASCII")) Upvote 0
something like Code: Copy Dim Job As HttpJob Job.Initialize("fcm", Me) Job.Download("https://www.google.com") 'Job.GetRequest.SetContentType("application/json;charset=UTF-8") Job.GetRequest.SetHeader("Authorization", "Basic "&Base64.encodeToString("rat#1:rat".getBytes(),Base64.NO_WRAP)) Note that you need to set the header AFTER job.download/poststring... Edit: The base64 you can do with stringutils and Byteconverter. Code: Copy su.EncodeBase64(bc.StringToBytes(USERNAME&":"&PASSWORD,"ASCII"))
O onair Member Licensed User Longtime User Jul 10, 2018 #4 Is this possible for each Header segment? Upvote 0
DonManfred Expert Licensed User Longtime User Jul 10, 2018 #5 you can use Code: Copy Job.GetRequest.SetHeader("xxx","yyy") multiple times if this is what you mean. Upvote 0
you can use Code: Copy Job.GetRequest.SetHeader("xxx","yyy") multiple times if this is what you mean.
O onair Member Licensed User Longtime User Jul 10, 2018 #6 I apologize that the google translation makes no sense, but the goal is that I can make settings for the header from PHP scripts in B4J. Specifically this part of PHP code: Code: Copy curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_REFERER, $this->baseurl.'/login'); curl_setopt($ch, CURLOPT_URL, $this->baseurl.'/api/login'); Upvote 0
I apologize that the google translation makes no sense, but the goal is that I can make settings for the header from PHP scripts in B4J. Specifically this part of PHP code: Code: Copy curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_REFERER, $this->baseurl.'/login'); curl_setopt($ch, CURLOPT_URL, $this->baseurl.'/api/login');
DonManfred Expert Licensed User Longtime User Jul 10, 2018 #7 If you want to use PHP then use it. If you want to send requests from b4j then you should use okhttputils. Yes, you can set referer and url headers. You just need to know the Headername (whats behind the CURLOPT_REFERER or CURLOPT_URL) to set it. Maybe you should learn english and do not rely on faulty google translations. Upvote 0
If you want to use PHP then use it. If you want to send requests from b4j then you should use okhttputils. Yes, you can set referer and url headers. You just need to know the Headername (whats behind the CURLOPT_REFERER or CURLOPT_URL) to set it. Maybe you should learn english and do not rely on faulty google translations.