noknok.in.th API #04 Update Status

มาต่อกันด้วย การ Update Status ของเราด้วย


new
URL: http://api.noknok.sanook.com/rest/message_new
Format: XML
Method(s): GET, POST
Parameters:
* authToken (required:GET)
* message (required:POST)
Return
* Sending message data

(ผ่านไปไม่กี่วัน URL เปลี่ยนซะแล้ว จาก http://api.noknok.in.th/rest/ เป็น http://api.noknok.sanook.com/rest)

ซึ่งคราวนี้จะต้องส่งแบบ POST เพราะฉะันั้นก็ต้องสร้าง FORM ไว้ส่ง
ก็เอาแบบง่าย ๆ นะครับ
$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=<< Update Status

message :



FORM;
echo $str;
}


noknok_update_status
ได้ผลดังรูป
noknok_update_status_ok

อ้อ อย่าลืมตั้งค่า Encoding เป็น UTF8 ด้วยนะครับ
Introduction
API Protocol
* Representational_State_Transfer(REST)
* HTTP Requests: Post and GET
Data Format
* XML, *Json, *RSS,*ATOM
Encoding
* UTF8

Comments

Popular posts from this blog

Artillery Hornet + OctoPrint + Klipper

ย้ายบ้าน

ใต้ร่มกาสาวพัตร