忍者ブログ
2024.06│ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
とりあえずtwitter botからPHPの世界に突入したいです。
2024年06月30日 (Sun)
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

2009年05月12日 (Tue)
前回からの続きで、ApacheとPHPをインストールしました。
インストール方法は以下のサイトを参考に。

Apacheのインストール
http://www.standpower.com/php_environment.html


PHPのインストール
http://www.standpower.com/php_environment2.html

PHPインストール後のApache再起動ですが、タスクバーのMonitor Apache ServersをExitして起動しなおすだけではだめなので注意。
XPの場合はすべてのプログラムからControl Apache ServerのRestartを実行します。


では動かしてみます!!

<?php
$url = "http://twitter.com/statuses/update.xml?";
$username = "rishitest";
$password = "password(ダミー)";
$params = "status=". rawurlencode("testtesttest");

$result = file_get_contents($url.$params , false, stream_context_create(array(
 "http" => array( "method" => "POST", "header" => "Authorization: Basic ".base64_encode($username. ":". $password)
 )
)));
?>


以上のプログラム(参照元はhttp://d.hatena.ne.jp/hirataka522/20080126/1201300282)を、テキストエディタに貼り付け、localhostのフォルダ内に「test.php」として保存。
ブラウザから「http://localhost/test.php」実行。


twitterを開いてみると。

http://twitter.com/rishitest/status/1772656331

でたー!!!POST成功です。
TLに「testtesttest」という投稿が表示されました。
これでbot作成への第1歩を踏み出しました。
PR
この記事にコメントする
お名前
タイトル
文字色
メールアドレス
URL
コメント
パスワード   Vodafone絵文字 i-mode絵文字 Ezweb絵文字
この記事へのトラックバック
この記事にトラックバックする:
←No.9No.8No.7No.6No.5No.4No.3No.2No.1
カレンダー
05 2024/06 07
S M T W T F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
プロフィール
HN:
リシ
性別:
非公開
自己紹介:
環境はWindowsXP HOME SP3です。
最新コメント
[12/23 luisapape]
[12/23 margerieah]
最新トラックバック
フリーエリア
バーコード
ブログ内検索
アーカイブ
P R
アクセス解析