From e87f59bd9463970d138f282d4ce3c92bd724b49d Mon Sep 17 00:00:00 2001 From: keita Date: Wed, 17 Feb 2021 10:53:42 +0900 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cocoatweet/api/interface/postInterface.cc | 5 +++-- src/cocoatweet/api/interface/postInterface.h | 2 +- src/cocoatweet/api/status/update.cc | 2 +- src/main.cc | 11 ++++++++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/cocoatweet/api/interface/postInterface.cc b/src/cocoatweet/api/interface/postInterface.cc index 68f93e3..da33bed 100644 --- a/src/cocoatweet/api/interface/postInterface.cc +++ b/src/cocoatweet/api/interface/postInterface.cc @@ -1,9 +1,10 @@ #include namespace CocoaTweet::API::Interface { -size_t postInterface::curlCallback_(char* _ptr, size_t _size, size_t _nmemb, std::string* _stream) { +size_t postInterface::curlCallback_(char* _ptr, size_t _size, size_t _nmemb, + std::string* _stream) { int realsize = _size * _nmemb; _stream->append(_ptr, realsize); return realsize; } -} // namespace CocoaTweet::API +} // namespace CocoaTweet::API::Interface diff --git a/src/cocoatweet/api/interface/postInterface.h b/src/cocoatweet/api/interface/postInterface.h index d45e1eb..a07f6e7 100644 --- a/src/cocoatweet/api/interface/postInterface.h +++ b/src/cocoatweet/api/interface/postInterface.h @@ -16,6 +16,6 @@ protected: std::string url_; static size_t curlCallback_(char* _ptr, size_t _size, size_t _nmemb, std::string* _stream); }; -} // namespace CocoaTweet::API +} // namespace CocoaTweet::API::Interface #endif diff --git a/src/cocoatweet/api/status/update.cc b/src/cocoatweet/api/status/update.cc index 293ed8f..5d689e1 100644 --- a/src/cocoatweet/api/status/update.cc +++ b/src/cocoatweet/api/status/update.cc @@ -67,7 +67,7 @@ void Update::process(std::weak_ptr _oauth, CURLcode res; std::string rcv; curl = curl_easy_init(); - url_ = url_;// + "?status=" + status_; + url_ = url_; // + "?status=" + status_; std::cout << "URL : " << url_ << std::endl; if (curl) { curl_easy_setopt(curl, CURLOPT_URL, url_.c_str()); diff --git a/src/main.cc b/src/main.cc index 81ee57d..1e702f3 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,12 +1,21 @@ #include "cocoatweet/oauth/key.h" #include "cocoatweet/api/api.h" +// 下記で使用しているAPI Keyはほぼ本物です. +// (再生成したので使用できないが,こんな感じで登録) auto main() -> int { auto consumerKey = "JRKUmkKFWiC3f7K6msLKaNNuP"; auto consumerSecret = "dTGI49MHRqa7XIFiPjwJR27vwolzsRaRXKA48iFlwAv4LK9Vlm"; auto accessToken = "2224351076-uF2XTmYeDdAfIsixuvfrwt8puLiPuwGe4w7RM8I"; auto accessTokenSecret = "dpCctbxzMjQ9AjZ6V7Fs6TIQlpPJo7JEkmjMfSO7QCEpW"; + + // キーオブジェクトを作成 CocoaTweet::OAuth::Key key(consumerKey, consumerSecret, accessToken, accessTokenSecret); + + // 作成したキーオブジェクトを用いてAPIを立ち上げる. + // 内部的にはキーオブジェクトを使用してOAuth認証機を立ち上げている. CocoaTweet::API::API api(key); - api.status().Update("tweet_from_Cocoa_Twitter_Library"); + + // クエリ文字列をURLエンコードしてないので,空白とか日本語とかはまだ無理. + api.status().Update("test"); }