2008-12-23
Delphiお勉強
ぐぐったりして見つけた情報源
- API(日本語訳):Twitter API 仕様書 日本語訳 第五十版 (2010年8月12日版)
- API(公式)(英語):no title
- なでしこプラグイン関連説明:no title(PHiValueについてなど)
- Basic認証:Basic認証 - Wikipedia
できたもの。
function sys_twitter_send(args: DWORD): PHiValue; stdcall; var account, password, status, head, body: string; p_id, p_pass, p_stat, p_url: PHiValue; begin // get Args account := getArgStr(args, 0); password := getArgStr(args, 1); status := getArgStr(args, 2); // rewrite p_id := nako_getVariable('ユーザー名'); p_pass := nako_getVariable('パスワード'); p_stat := nako_getVariable('発言内容'); hi_setStr(p_id, account); hi_setStr(p_pass, password); hi_setStr(p_stat, status); hi_setStr(p_url, 'http://twitter.com/statuses/update.xml'); head :='Authorization: Basic ' & sys_Base64Encode(p_id & ':' & p_pass); body :='status=' & sys_URLEncode(sys_toUTF8N(p_stat)); //発言内容が「」なら、なにもしない。 if p_stat = '' then exit; // update Result := hi_newStr(sys_http_post(head, body, url)); end;
まだまだ未確認のまま適当に書いているところが多いです。
-hi_newStrとは?
--なでしこの値を文字列型で生成して返す関数です。
- 文字列の接続の書き方は?
--Delphiだと + で文字列でも何でも足し算です。
- if文の書き方は?
--if (e) then begin xx end else begin xxx end;
-sys_URLEncodeとかはこんな感じで呼べるのか?
--Delphiで作った関数に URLEncode(だったかな?)があるのでこれを使用します。sys_xxx は、なでしこ側へ登録する関数なので、そのまま呼べません。
-関数からの抜け方は?(exit?)
--Exit でOKです。
-というか、抜けちゃっていいのか?(エラーにするべき?)
--OKです。エラーを出したいときは、raise Exception.Create('メッセージ') って感じです。
何でも聞いてくださいね!