February 24th, 2009

You are currently browsing the articles from KomKid.Net written on February 24th, 2009.

noknok.in.th API #05 Direct Message

มาต่อกันด้วยการส่งตรง Message ถึงเพื่อนที่เราต้องการ

URL: http://api.noknok.sanook.com/rest/direct_message_new
Format: xml
Method(s): POST
Parameters:
* authToken (required:GET)
* message (required:POST)
* message_to (required:POST)
Return:
* Sending status (true or false)

ก็เอา code เดิมมาแก้ไข form นิดหน่อย

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$base         = 'http://api.noknok.sanook.com/rest/auth';
$query_string = 'username=komkid&password=******';
 
$url = "$base?$query_string";
 
$xml = file_get_contents($url);
$dom = new DOMDocument('1.0', 'UTF-8');
if ($dom->loadXML($xml) === false) {
   die('Parsing failed');
}
 
$res = xml_to_result($dom);
if($res["stat"] == "ok"){
  $query_string = 'authToken='.$res["authToken"];
  $str=     " Send Direct Message <br>";
  $str.=    "<form method=\"post\" action=\"http://api.noknok.sanook.com/rest/direct_message_new?$query_string\">";
  $str.=    "message : <input type=\"text\" name=\"message\"><br>";
  $str.=    "send to : <input type=\"text\" name=\"message_to\"><br>";
  $str.=    "<input type=\"submit\" value=\"send\">";
  $str.=    "</form>";
  echo $str;
}

ได้ form ดังรูป
noknok_api_direct_message_form

แล้วก็ได้ผลดังนี้

noknok_api_direct_message_ok

Written by Komkid on February 24th, 2009 with no comments.
Read more articles on Internet and Programming.