I have been struggling with authentication with BING API. Here I have the following code which works in Java, there are MANY examples in c#, perl, php and in java although I am struggling to port to B4A
I have the following code in Java
So far this is what I have done to replicate this.
although I am struggling with the last part
I have no idea how to replicate this using HttpUtils specifically this line
I have the following code in Java
String bingUrl = "https://api.datamarket.azure.com/Bing/Search/................";
String accountKey = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
byte[] accountKeyBytes = Base64.encodeBase64((accountKey + ":" + accountKey).getBytes());
String accountKeyEnc = new String(accountKeyBytes);
URL url = new URL(bingUrl);
URLConnection urlConnection = url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic " + accountKeyEnc);
So far this is what I have done to replicate this.
Dim bingUrl As String
Dim accountKey As String
Dim accountKeyBytes As String
Dim accountKeyEnc As String
bingUrl = "https://api.datamarket.azure.com/Bing/Search/Image?$format=json&Query=%27"& word &"%27"
accountKey = "V+DZ2f+ZgI6W9mzOihz2KmRoeBHX0AoqLMKSAU9tpl0"
accountKeyBytes = b64.EncodeStoS(accountKey & ":" & accountKey,"UTF-8")
accountKeyEnc = accountKeyBytes
although I am struggling with the last part
URL url = new URL(bingUrl);
URLConnection urlConnection = url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic " + accountKeyEnc);
I have no idea how to replicate this using HttpUtils specifically this line
urlConnection.setRequestProperty("Authorization", "Basic " + accountKeyEnc);