วันพฤหัสบดีที่ 8 เมษายน พ.ศ. 2553

Twitter API

ถึงเวลาเปลี่ยนแปลง โลกเปลี่ยน สไตล์การเขียนเว็บก็เปลี่ยน "New trends" Time to change,
When talk about Api, we know easy api like two thing, one is Javascript and another one is Xml.
เหมือนกัน ถ้า พูดถึง Application Programming Interface (API). แล้วละก็เราจะถึง google apis, paypal api etc... ในเมื่อคนทั่วโลกสนใจ twitter เป็นอันดับ 12 เราก็ต้องมาศึกษาเพิ่มถึงการทำงานกับมัน รวมถึงก้าวผ่าน มายัง เว็บ 2.0 อย่างเต็มตัว โดยการ เพิ่ม social network เพิ่มเพิ่มระดับความน่าสนใจของเว็บเรา

ตัวอย่างใช้ api กับเฟรมเวิร์ก Yii

'twitter' => array(
'class' => 'application.extensions.twitter.VGTwitter', // path to the twitter extension
'username' => 'LOGINNAME', // login name, this is not required all the time but most api calls need this set
'apiCallType' => 'statuses/home_timeline', // the api call to perform, the default is set to statuses/user_timeline
'password' => 'PASSWORD', // password for the twitter account
'authenticate' => true, // if the twitter api call needs authentication then this must be set to true since by default it is set to false
'format' => 'rss', // default is xml so we will configure this as rss for this example
'postParams' => array( 'count' => 2 ) // we want only the first two results, meaning tweets
),

การใช้งานแค่
CVarDumper::dump(Yii::app()->twitter->get()->getResponseData(), 10, true);

ได้ค่า xml มาใช้ ฟังก์ชั่นอ่านเพิ่มใช้งานต่อไป

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

ผู้ติดตาม