มี ที่ นี่

พล ส้ม's Blog

Archive for the ‘web 3.0’ Category

ประโยชน์ของ Tag เกี่ยวกับ SEO

1 Comment »

January 5th, 2009 Posted 5:24 pm

หลายๆคนเปิด option เกี่ยวกับ tag และใส่ไปโดยไม่ได้คาดหวังอะไร เพราะเห็นว่ามีและคนอื่นบอกว่าดี ผมขอบอกเลยนะครับว่า สงสัยต้องคิดดีๆ ก่อนใส่ซะหน่อยแล้ว

tag นั้นเป็นสิ่งที่เราจะต้องใส่เอง เป็นคำที่บ่งบอกเกี่ยวกับเนื้อหา หรืออะไรก็ตามที่จะตามมาที่จะตามมาที่ บทความ หรือ สินค้านั้นๆได้

tag เองไม่ได้ถูกนำมาใช้กับบทความอย่างเดียว แต่ยังนำมาใช้กับสินค้าได้อีกด้วย ประโยนช์ของ tag นั้นมากมายเหลือเกินจนเราอาจจะต้องขอบคุณคนที่คิดค้นคำว่า tag เลยทีเดียว

tag เองไม่ได้ถูกเพิ่มด้วยระบบจะต้องใส่ลงไปเอง ทำให้คนใส่นั้นเกิดอาการขี้เกียจขึ้นมาในทันที และอารมณ์ของการใส่นั้นช่างเป็นอะไรที่ไม่อยากใส่เป็นอย่า่งยิ่ง ถ้าไม่มีจัดประสงค์และความพยายามพอควรเพราะ tagจะใส่หลังเนื้อความ เมื่อความในใจหมดไปแล้ว ความว่างเปล่าก็เิกิดขึ้นไม่รู้จะใส่อะไร

tag นั้นในบางระบบถึงกับมีการ generate ออกมาเลยทีเดียว ซึ่ง tag นั้นมาจาก คำที่เกิดบ่อยครั้งในเนื้อหา ตัวหน้า การเน้นเนื้อหา, มาจาก title และมาจาก keyword  จะเห็นว่า tag นั้นเป็นเหมือนกับการค้นหาคำสำคัญนั่นเอง แต่คนที่คิดว่ามันมีประโยชน์นั้นจะมีสักกี่คน

คราวนี้เราจะมาดูประโยชน์ของ tag ที่เกี่ยวกับ SEO กันครับ tag เวลาที่เราจะทำให้ page นั้นมี rank สูงๆ แข่งกับคนอื่นได้ แน่นอนว่าเราต้องให้หน้าเว็บนั้นๆ มี keyword นั้นพอประมาณขึ้นอยู่กับเนื้อหาด้วยว่าจะมีขนาดมากน้อยขนาดใหน แต่จะต้องมีมากหรือน้อยนี่แหละครับ ที่เราเองไม่รู้เลยว่า ความเหมาะสมมันอยู่ตรงใหน ซึ่งหลายๆ คนก็เอาความประมาณและเนื้อหาที่พอประมาณมาวัดแล้วลอง ก็จะได้ เป็น % ที่น่าจะดีออกมา ไม่บอกนะว่ากี่%

แต่ถ้าเราพยายามพี่จะทำหน้านั้นให้ดีกว่าหน้าอื่นซึ่งอยู่บนโลก internet อีกแสนหน้าล้านหน้า เราจะทำได้หรือเปล่า นั่นน่ะซิ แล้วทำไมไม่เห็นพูดเรื่อง tag เลย ไม่เห็นเกี่ยวกับ tag เลย tag จะช่วยอะไรได้ ผมบอกได้เลยนะครับว่า tag นั้นช่วยได้จริงๆ

เวลาที่ tag cloud อยู่บนหน้าเว็บนั้น จะทำให้หน้าที่เป็น index ของ tag แต่ละคำและ link ของ tag จะเป็นการดึงข้อมูลที่มี tag เหมือนกันออกมา ลองคิดดูนะครับว่า ถ้าเรามีบทความ 5 บทความ เนื้อหาข้างในคล้ายๆกัน tag ย่อมคล้ายคลึงกันและมีคำเดียวกันอยู่ด้วย เวลาที่ search คำนั้นออกมาแหละครับผลลัพท์ที่ออกมาคือการได้เนื้อหาที่คล้ายๆกันออกมา และยังระบุเป็นคำได้เลยดด้วย

เหมือนกับเรา SEO กับหน้านึงเลยทีเดียว ไม่ต้องเขียน content ยาวๆเกี่ยวกับ keyword นั้นๆอีกต่อไป เราก็มี index ดีๆได้โดยมาจากการ generate ซะด้วยซ้ำ

ยิ่งคุณมี tag ในแต่ละบทความมากๆ และบทความเยอะๆ  index ที่เป็นคำเน้นๆ ยิ่งมากขึ้นไปอีก

จากที่เราได้บอกเกี่ยวกับข้อดีของมันมาซะเยอะ แต่คนที่ใส่ tag ตอนนี้นั้นใส่มั่วๆไป ใส่คำ 2 คำ ทำให้ tag ที่ออกมานั้นเป็น keyword น้อย ทำให้ไม่เห็นผลเท่าใหร่

ลองดูนะครับใส่ tag แบบเกี่ยวกับเนื้อหาจริงๆ เป็นชื่อ category ยังได้เลย อะไรที่เป็นตัวหน้าก็เอามาเป็น tag เลยก็ได้ เพราะถือว่าเราเน้นแล้ว แล้วจะได้ index อีกเยอะ

เก็บงาน CMS เว็บสำเร็จรูป

No Comments »

January 5th, 2009 Posted 10:01 am

ตอนนี้เขียน shopping component จะเสร็จแล้ว สงสัยต้องวาง road map ของการ test ซะหน่อยแล้วว่าจะ Test กี่เว็บแล้วขายอะไรดีบ้างทำ keyword กี่ keyword แล้วจะติดใหม อิอิ

ที่เขียนๆ ไปแล้ว Test ไม่ได้เองคือ payment gateway นั่นเอง เพราะยังไม่ได้ Test Gateway เลย

ส่วน Roadmap ที่เหลือ ก็จะมี web directory component  และ webboard component และ photo gallery component อิอิ อีก 3 อันนี้เสร็จก็เว็บเบิ้มแล้ว

twitpic api test – curl

No Comments »

December 29th, 2008 Posted 5:41 pm

อิอิ วันนี้ว่างมากๆ เลยมั้งนั่งเขียน อะไรเล่นใหญ่เลยคราวนี้มาเป็น twitpic บ้างเพราะ twitter เองนั้นทำ api ให้เราได้ใช้กันแบบง่ายมากๆ คุณ sugree ยังบอกเลยว่ามันง่ายมำให้คนใช้งานได้ง่ายๆ ทำให้ดังได้ง่ายๆ หุหุ

แล้วผมเองก็เขียน PHP ด้วยมาดูกันเลยแล้วกันครับว่า เป็นไงบ้าง


<?php
class xx_xml {

// XML parser variables
var $parser;
var $name;
var $attr;
var $data  = array();
var $stack = array();
var $keys;
var $path;

// either you pass url atau contents.
// Use ‘url’ or ‘contents’ for the parameter
var $type;

// function with the default parameter value
function xx_xml($url=’http://www.opocot.com’, $type=’url’) {
$this->type = $type;
$this->url  = $url;
$this->parse();
}

// parse XML data
function parse()
{
$data = ”;
$this->parser = xml_parser_create();
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, ’startXML’, ‘endXML’);
xml_set_character_data_handler($this->parser, ‘charXML’);

xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);

if ($this->type == ‘url’) {
// if use type = ‘url’ now we open the XML with fopen

if (!($fp = @fopen($this->url, ‘rb’))) {
$this->error(“Cannot open {$this->url}”);
}

while (($data = fread($fp, 8192))) {
if (!xml_parse($this->parser, $data, feof($fp))) {
$this->error(sprintf(‘XML error at line %d column %d’,
xml_get_current_line_number($this->parser),
xml_get_current_column_number($this->parser)));
}
}
} else if ($this->type == ‘contents’) {
// Now we can pass the contents, maybe if you want
// to use CURL, SOCK or other method.
$lines = explode(“\n”,$this->url);
foreach ($lines as $val) {
if (trim($val) == ”)
continue;
$data = $val . “\n”;
if (!xml_parse($this->parser, $data)) {
$this->error(sprintf(‘XML error at line %d column %d’,
xml_get_current_line_number($this->parser),
xml_get_current_column_number($this->parser)));
}
}
}
}

function startXML($parser, $name, $attr)    {
$this->stack[$name] = array();
$keys = ”;
$total = count($this->stack)-1;
$i=0;
foreach ($this->stack as $key => $val)    {
if (count($this->stack) > 1) {
if ($total == $i)
$keys .= $key;
else
$keys .= $key . ‘|’; // The saparator
}
else
$keys .= $key;
$i++;
}
if (array_key_exists($keys, $this->data))    {
$this->data[$keys][] = $attr;
}    else
$this->data[$keys] = $attr;
$this->keys = $keys;
}

function endXML($parser, $name)    {
end($this->stack);
if (key($this->stack) == $name)
array_pop($this->stack);
}

function charXML($parser, $data)    {
if (trim($data) != ”)
$this->data[$this->keys]['data'][] = trim(str_replace(“\n”, ”, $data));
}

function error($msg)    {
echo “<div align=\”center\”>
<font color=\”red\”><b>Error: $msg</b></font>
</div>”;
exit();
}
}

if(isset($_POST)){

if (!empty($_FILES['media']['name'])) {

$localfile = $_FILES['media']['tmp_name'];

if (!copy($localfile, $_FILES['media']['name'])) {
echo “failed to copy $file…\n”;
}

$localfile = $_FILES['media']['name'];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “http://twitpic.com/api/uploadAndPost”);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// same as <input type=”file” name=”file_box”>
$post = array(
“media”=> ‘@’.getcwd().’/’.$localfile,
“username”=> $_POST['username'],
"password"=>
$_POST['password'],
"message"=> $_POST['message'],
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);

$content = new xx_xml($response, ‘contents’);

$status = $content->data['rsp']['status'];
$imageUrls = $content->data['rsp|mediaurl']['data'];

unlink(getcwd().’/’.$localfile);

foreach($imageUrls as $url){
header(“Location: “.$url);
exit();
}
}
}

?>

<form name=”twitterForm” action=”" method=”post” enctype=”multipart/form-data”>

media. <input type=”file” name=”media” /><br />
username. <input type=”text” name=”username” value=”" /><br />
password. <input type=”text” name=”password” value=”" /><br />
message. <input type=”text” name=”message” value=”" /><br />
<input type=”submit” value=”OK” />
</form>
อิอิ แค่ง่ายๆ นะไม่ได้ยุ่งยากอะไรมาก ก็คือ ปกติแล้วเราจะต้องส่งไปแบบหน้า post จาก form ปกติ แต่คราวนี้เรามา post แบบ cUrl ไว้ (ตรวจสอบดูก่อนนะว่า web server ได้ลง cUrl เปล่าไม่ลงใช้ไม่ได้นะ)  แล้วก็ทำการ postเหมือน form เลย

ใครจะลองเอาไปทำอะไรเล่นก็เอานะลองเข้าไปดูตัวอย่างเล่นๆ ได้ที่ http://www.meteenee.com/twitterapi/

ปตท web service

No Comments »

December 29th, 2008 Posted 1:26 pm

วันๆ ว่างๆ ไม่รู้จะทำอะไร เหลือบมองเห็นช่องราคาน้ำมันจากหน้าเว็บเลย เข้าไปดู กลายเป็น Iframe ซึ่งไม่ค่อยชอบเท่าใหร่ เลยไปดูว่าเอาข้อมูลมาจาใหน ที่แท้เป็น frame ที่ได้จากเว็บของ ปตทเลยนี่เอง เลื่อนลงมาล่างๆ หน่อยมี web service ให้ยริการด้วย เลยแก้ว่างด้วยการเขียน web service เรียกราคาน้ำมันซะเลย

ในการเขียนครั้งนี้ก็ไม่ได้ เวอร์ หลูหลา สะแมนแตน อะไรมากมาย แค่PHP+ lib ของ nusoup ตัวเดียวเท่านั้น ถ้าไม่มี lib ตัวนี้อยู่ก็เข้า google แล้วหาคำว่า nosoap รับลองเจอ

php เองจะว่าว่าเป็นของเด็กๆ ก็ทำอะไรที่ Enterprise กับเข้าได้เหมือนกันนะ ที่เห็นว่าเป็นเด็กๆ หรือ Basic เพราะอะไรหลายๆ อย่างไม่บอกดีกว่า มาเขียนกันดีกว่า

เริ่มแรกก็ เข้าไปที่ http://www.pttplc.com/th/nc_oi.aspx ซะก่อน บอกแล้วว่าล่างๆ จะบอกว่า web service ด้วย และก็มีมาให้ครบเลยทั้ง WSDL และเอกสารด้วย อ่านกันได้ตามสบาย

ทีนี้เรารมาดูวิธีการเขียนด้วย nusoap กันดีกว่า

require_once('./lib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$client = new nusoap_client('http://www.pttplc.com/pttinfo.asmx?wsdl',</code>

<code> 'wsdl', $proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client-&gt;getError();
if ($err) {
echo '
</code>
<h2>Constructor error</h2>
<pre>' . $err . '</pre>
';
}

$operation = 'CurrentOilPrice';
$client-&gt;decodeUTF8(false);
$result = $client-&gt;call(
$operation,
array('Language' =&gt; 'TH')
);

// Check for a fault
if ($client-&gt;fault) {
echo '
<h2>Fault</h2>
<pre>';

print_r($result);

echo '</pre>
';
exit();
}

// Check for errors
$err = $client-&gt;getError();
if ($err) {
// Display the error
echo '
<h2>Error</h2>
<pre>' . $err . '</pre>
';
exit();
}

$result = $result['CurrentOilPriceResult'];
$content = new xx_xml($result, 'contents');
$PRICE_DATE = $content-&gt;data['PTT_DS|Table|PRICE_DATE']['data'];
$PRODUCT = $content-&gt;data['PTT_DS|Table|PRODUCT']['data'];
$PRICE = $content-&gt;data['PTT_DS|Table|PRICE']['data'];

?&gt;

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style> table{  width:350px;  border:1px solid #999999; }

table th{  background-color:#3f3f3f;  color:#FFFFFF; }

.hl{  background-color:#EFEFEF; }

</style>
<table>
<tr>
<th>Type</th>
<th>Price</th>
<th>Update date</th>
</tr>
<tr>
<td></td>
<td align="center"></td>
<td align="center"></td>
</tr>
</table>
class xx_xml {

// XML parser variables
var $parser;
var $name;
var $attr;
var $data  = array();
var $stack = array();
var $keys;
var $path;

// either you pass url atau contents.
// Use 'url' or 'contents' for the parameter
var $type;

// function with the default parameter value
function xx_xml($url='http://www.opocot.com', $type='url') {
$this-&gt;type = $type;
$this-&gt;url  = $url;
$this-&gt;parse();
}

// parse XML data
function parse()
{
$data = '';
$this-&gt;parser = xml_parser_create();
xml_set_object($this-&gt;parser, $this);
xml_set_element_handler($this-&gt;parser, 'startXML', 'endXML');
xml_set_character_data_handler($this-&gt;parser, 'charXML');

xml_parser_set_option($this-&gt;parser, XML_OPTION_CASE_FOLDING, false);

if ($this-&gt;type == 'url') {
// if use type = 'url' now we open the XML with fopen

if (!($fp = @fopen($this-&gt;url, 'rb'))) {
$this-&gt;error("Cannot open {$this-&gt;url}");
}

while (($data = fread($fp, 8192))) {
if (!xml_parse($this-&gt;parser, $data, feof($fp))) {
$this-&gt;error(sprintf('XML error at line %d column %d',
xml_get_current_line_number($this-&gt;parser),
xml_get_current_column_number($this-&gt;parser)));
}
}
} else if ($this-&gt;type == 'contents') {
// Now we can pass the contents, maybe if you want
// to use CURL, SOCK or other method.
$lines = explode("\n",$this-&gt;url);
foreach ($lines as $val) {
if (trim($val) == '')
continue;
$data = $val . "\n";
if (!xml_parse($this-&gt;parser, $data)) {
$this-&gt;error(sprintf('XML error at line %d column %d',
xml_get_current_line_number($this-&gt;parser),
xml_get_current_column_number($this-&gt;parser)));
}
}
}
}

function startXML($parser, $name, $attr)    {
$this-&gt;stack[$name] = array();
$keys = '';
$total = count($this-&gt;stack)-1;
$i=0;
foreach ($this-&gt;stack as $key =&gt; $val)    {
if (count($this-&gt;stack) &gt; 1) {
if ($total == $i)
$keys .= $key;
else
$keys .= $key . '|'; // The saparator
}
else
$keys .= $key;
$i++;
}
if (array_key_exists($keys, $this-&gt;data))    {
$this-&gt;data[$keys][] = $attr;
}    else
$this-&gt;data[$keys] = $attr;
$this-&gt;keys = $keys;
}

function endXML($parser, $name)    {
end($this-&gt;stack);
if (key($this-&gt;stack) == $name)
array_pop($this-&gt;stack);
}

function charXML($parser, $data)    {
if (trim($data) != '')
$this-&gt;data[$this-&gt;keys]['data'][] = trim(str_replace("\n", '', $data));
}

function error($msg)    {
echo "
<p align="\">             <font color="#00ed00"><strong>Error: $msg</strong></font></p>
";
exit();
}
}

?>

อันนี้ที่เห็นเป็น Code คร่าวๆ นะ จะได้หน้าตาแบบ หน้านี้ ครับ ไปที่นี่เลย http://www.meteenee.com/pttservice/index.php

จะว่าไปแล้วก็ขอบคุณ ปตท. นะ เพราะว่า บ้านเรานี้ไม่ค่อยมี service ให้ใช้เลย เฮ้อ รอต่อไป รอหน่วยงานที่เห็นถึงความสำคัญ

เว็บสำเร็จรูป -module tag cloud

No Comments »

November 17th, 2008 Posted 5:09 pm

tag cloud นั้นเป็นอีกสิ่งที่สำคัญเลย อิิอิใน web 2.0 -3.0ไม่ว่า 2.0 นั้นจะเปลี่ยนไปเป็น 3.0 เร็วขนาดใหน แต่การที่เปลี่ยนเป็น web 2.0 นั้นช่างมากเหลือเกิน ไม่ว่าจะเป็น CSS, feed หรืออะไรอีกหลายอย่าง ทำให้สิ่งพวกนี้ยังเป็นพื้นฐานต่อไปเรื่อยได้สิ่งที่จะให้มีคือ tag cloud ครับโดย เป็น tag ของสินค้าและ article(content) ต่างๆ โดยการได้มานี้ ก็จะได้มาจา่กการใส่ของ user เอง และการเพิ่มให้จากระบบครับการเพิ่มเองด้วยมือคงไม่ต้องพูดอะไรมาก แต่การให้ระบบสร้าง tag ขึ้นมาเองนี่ซิครับ tag นั้นคือคำสำคัญๆ ของสิ่งนั้นๆ เพราะฉนั้นถ้าเป็น article ก็จะเป็น อักษรตัวหนา เป็น อักษรเีอียง ที่สำคัญ และก็ ข้อมูลที่อยู่ใน tag h ต่างๆครับเราก็เอามาตัดออกเป็นคำๆ แล้วเราก็จะได้ tag ออกมา