You can basically do the exact same thing that the code snippet shows you. Just replace HttpURLConnection ...
stackoverflow.com