Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Wylex

Pages: [1]
1
Network / Re: Error 301
« on: April 17, 2016, 12:31:15 am »
Thanks again, works fine now.

2
Network / Error 301
« on: April 16, 2016, 07:56:33 pm »
Well, I keep trying to use the API I mentioned on the last post https://www.themoviedb.org/ but... beginnings were never easy I guess.

I have another problem now, here's the thing: I'm trying to use the search/movie function but again even if on my browser works fine it doesn't when I try to program it.

       
sf::Http http("http://api.themoviedb.org");

sf::Http::Request request;
request.setMethod(sf::Http::Request::Get);
request.setUri("/3/search/movie/?api_key=###&query=Interstellar");
 

According to the documentation, this function needs the api key and the name of the movie you're looking for witch must be a "CGI escaped string". If I'm not wrong, the escaped string shouldn't change anything if I'm looking for a one word movie tittle (in this case Interstellar).

Anyway, with the code above, the status of the request is 301 (Moved permanently). I've try to look why it isn't working but I just don't know why nor how I can fix that. Any idea? Thanks

3
Network / Re: Web requests
« on: April 16, 2016, 11:37:02 am »
Ok, I think it works now, thanks. I'll take a look at the HTTP protocol as you said Nexus.

4
Network / Re: Web requests
« on: April 15, 2016, 09:00:13 pm »
The WWW-Authenticate was something I read on the web and I thought was worth a try.

Besides that, I read on the tutorial that: "The body of the page (used only with the POST method)" so I assumed I didn't have to use the setBody function (I'm using a Get method... right?) though I tried already anyway but it didn't change anything.

Is it possible there's something wrong elsewhere?

5
Network / Web requests
« on: April 15, 2016, 08:13:19 pm »
Hi,

I've never used a REST API before but I'd like to get introduced to them.

I wanted to learn what they are and how to use them so I've picked up one for testing its functionalities. I found this https://www.themoviedb.org/ movie database that provides some interesting functions. I learned how to use those functions on my browser with urls like "http://api.themoviedb.org/3/discover/movie?api_key=###" and know I'd like to use those methods on a c++ program.

I found the sfml tutorial http://www.sfml-dev.org/tutorials/2.3/network-http.php  that if I'm not wrong explains how to do it, however there's something I'm doing wrong:

I followed the tutorial and wrote this:
#include <iostream>
#include <SFML/Network.hpp>

int main() {
        sf::Http http("http://api.themoviedb.org/3/");

        sf::Http::Request request;
        request.setMethod(sf::Http::Request::Get);
        request.setUri("/movie/popular");

        sf::Http::Response response = http.sendRequest(request);
        std::cout << "status: " << response.getStatus() << std::endl;
        std::cout << "HTTP version: " << response.getMajorHttpVersion() << "." << response.getMinorHttpVersion() << std::endl;
        std::cout << "Content-Type header:" << response.getField("Content-Type") << std::endl;
        std::cout << "body: " << response.getBody() << std::endl;

        return 0;
}
 

The status response is always 1001 witch means "connection failed". I know I need to pass the api_key since its a required parameter but I don't know how. I tried this:
request.setField("WWW-Authenticate", "###");
But I get the same status response.

Could anyone point me to the right direction please? I'm quite lost, it's the first time I try to use this libraries.

Note: I replaced my personal API key with "###"

Pages: [1]
anything