From e6a83053cbe080a86c3566510d5870d4f103a2d5 Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Tue, 25 May 2010 03:21:37 +0000 Subject: [PATCH] + add the demo of api. --- bin/getbugs.php | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 bin/getbugs.php diff --git a/bin/getbugs.php b/bin/getbugs.php new file mode 100644 index 0000000000..79905028ec --- /dev/null +++ b/bin/getbugs.php @@ -0,0 +1,62 @@ +fetch($sessionAPI); +$session = json_decode($snoopy->results); + +/*用户登录*/ +$submitVars["account"] = $account; +$submitVars["password"] = $password; +$snoopy->cookies[$session->sessionName] = $session->sessionID; +$snoopy->submit($loginAPI, $submitVars); + +/* 直接调用my模块的bugs页面。*/ +$snoopy->fetch($myBugAPI . "&$session->sessionName=$session->sessionID"); +$result = json_decode($snoopy->results); +if($result->bugs) +{ + foreach($result->bugs as $bug) echo $bug->title . "\n"; +} +else +{ + echo 'no bugs' . "\n"; +} +/* 通过超级model调用。*/ +$snoopy->fetch($superMyBugAPI . "&$session->sessionName=$session->sessionID"); +$result = json_decode($snoopy->results); +if(is_array($result)) +{ + foreach($results as $bug) echo $bug->title . "\n"; +} +else +{ + echo 'no bugs' . "\n"; +} +?>