diff options
Diffstat (limited to 'sap.cpp')
-rw-r--r-- | sap.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/sap.cpp b/sap.cpp index 4e2f66c..56fb677 100644 --- a/sap.cpp +++ b/sap.cpp | |||
@@ -18,6 +18,13 @@ extern "C" { | |||
18 | #include <thread> | 18 | #include <thread> |
19 | #include <chrono> | 19 | #include <chrono> |
20 | 20 | ||
21 | /* - random frames from Spongebob (using ffmpeg) | ||
22 | * with strange text overlaid, possibly rawr'd from | ||
23 | * spongebob transcripts combined with drug trip | ||
24 | * experiences? either that or something with verb | ||
25 | * frames | ||
26 | */ | ||
27 | |||
21 | template <class Container> | 28 | template <class Container> |
22 | Container split(std::string input, std::string delimiter) | 29 | Container split(std::string input, std::string delimiter) |
23 | { | 30 | { |
@@ -442,25 +449,16 @@ int main(int argc, char** argv) | |||
442 | 449 | ||
443 | std::cout << "Generated image." << std::endl << "Tweeting..." << std::endl; | 450 | std::cout << "Generated image." << std::endl << "Tweeting..." << std::endl; |
444 | 451 | ||
445 | long media_id; | 452 | try |
446 | twitter::response resp = client.uploadMedia("image/jpeg", (const char*) outputimg.data(), outputimg.length(), media_id); | ||
447 | if (resp != twitter::response::ok) | ||
448 | { | 453 | { |
449 | std::cout << "Twitter error while uploading image: " << resp << std::endl; | 454 | long media_id = client.uploadMedia("image/jpeg", (const char*) outputimg.data(), outputimg.length()); |
450 | 455 | client.updateStatus("", {media_id}); | |
451 | break; | ||
452 | } | ||
453 | 456 | ||
454 | twitter::tweet tw; | 457 | std::cout << "Done!" << std::endl << "Waiting..." << std::endl << std::endl; |
455 | resp = client.updateStatus("", tw, twitter::tweet(), {media_id}); | 458 | } catch (const twitter::twitter_error& error) |
456 | if (resp != twitter::response::ok) | ||
457 | { | 459 | { |
458 | std::cout << "Twitter error while tweeting: " << resp << std::endl; | 460 | std::cout << "Twitter error: " << error.what() << std::endl; |
459 | |||
460 | break; | ||
461 | } | 461 | } |
462 | |||
463 | std::cout << "Done!" << std::endl << "Waiting..." << std::endl << std::endl; | ||
464 | 462 | ||
465 | break; | 463 | break; |
466 | } | 464 | } |