#include #include #include #include #include #include #include #include #define DEBUG_LEVEL -1 int main(int argc, char *argv[]) { if(argc != 3) { std::cerr<< argv[0] << ": Usage: " << " apiurl contentkey" << std::endl; return -1; } char url_posts[128], url_pages[128]; snprintf(url_posts, sizeof url_posts, "%s/ghost/api/content/posts/?key=%s&limit=all", argv[1], argv[2]); snprintf(url_pages, sizeof url_pages, "%s/ghost/api/content/pages/?key=%s", argv[1], argv[2]); if (DEBUG_LEVEL > 0) std::cout<<"urls to fetch are "< 0) std::cout << request1 << std::endl; std::ofstream outfile; outfile.open ("posts.json"); outfile << curlpp::options::Url(url_posts) << std::endl; outfile.close(); request2.setOpt(new curlpp::options::Url(url_pages)); if (DEBUG_LEVEL > 0) std::cout << request2 << std::endl; outfile.open ("pages.json"); outfile << curlpp::options::Url(url_pages) << std::endl; outfile.close(); return EXIT_SUCCESS; } catch ( curlpp::LogicError & e ) { if (DEBUG_LEVEL > 0) std::cout << e.what() << std::endl; } catch ( curlpp::RuntimeError & e ) { if (DEBUG_LEVEL > 0) std::cout << e.what() << std::endl; } return EXIT_FAILURE; }