I have some experience with hi-level languages but I'm still learning C++ and trying to create an application with JUCE. I'm slowly getting things to work but I'm really missing some simple examples to understand things faster.
In this project I'll be working mostly with HTTP Request, so I'm trying to use the URL library to login to website. I need to do a GET request and the page will return a token in the response (that part works ok), then I need to send a POST request with login data and that token.
I also need to get the Cookies from the Response Headers but I can't figure out how to retrieve the contents from createInputStream(). I'm lost as how to work with StringPairArray*.
I'm sorry, this must be a stupid question but I'm not entirely familiar with the language and I've searched everywhere for an example but couldn't find any. If someone could show me how to login to a website and retrieve the response headers it would help me proceed with my project.
I've made a test program to try to login to this forum but the response text shows that I'm not logged in. Besides my attempts to retrieve the responseHeaders have all failed with a Access violation exceptions, so I must be doing it wrong.
StringPairArray* responseHeaders; String strHeaders = "Referer: http://www.juce.com/user/login\r\n" "User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)\r\n" "Content-Type: application/x-www-form-urlencoded\r\n"; URL url("http://www.juce.com/user/login"); url = url.withPOSTData("name=Pulover&pass=MyPassword&form_id=user_login&op=Log+in"); url.createInputStream(true, 0, 0, strHeaders, 30000, responseHeaders); String response = url.readEntireTextStream(); DBG (response); // This returns the same login page, not the logged-in page. //StringArray values = responseHeaders->getAllKeys(); // This gives me an Access violation exception.
If I could get this to work I think I'd be able to complete the other parts.
Thanks in advance.