Google Spell Check API

MAMP မှာ pspell ကို မထည့်ထားလို့ ornagai မှာ spell checking ကို ဖြုတ်လိုက်ရတယ်။ ဒါပေမယ့် စိတ်က သိပ်မကျေနပ်ဘူး။ ပြန်ထည့်မယ်ဆိုပြီး စဉ်းစားပေမယ့် php ကို ပြန် compile လုပ်ရမှာကြောင့် မလုပ်ဖြစ်ဘူး ဖြစ်နေတယ်။ ဒါနဲ့ google က api လေး ပေးထားရင်တော့ php လည်း ပြန်ပြီး compile လုပ်စရာမလိုဘူး။ server တိုင်းအတွက်လည်း သုံးလို့ရသွားမယ်ဆိုပြီး ရှာလိုက်တော့ တွေ့ပါတယ်ဗျာ။ code ကလည်း လွယ်လွယ်လေးပဲ။ code example ကို အောက်မှာပဲ ကြည့်လိုက်ပါ။ ornagai.com မှာတော့ အမြန်ဆုံး ထည့်သွင်းနိုင်အောင် ကြိုးစားလိုက်အုံးမယ်။ Ornagai.com ကို v3 အနေနဲ့ ပြန်ရေးမယ်ဆိုတာကလည်း မရေးဖြစ်သေးဘူး။ ဒီ spell check ကိုတော့ ဒီအပတ်အတွင်း ထည့်နိုင်အောင် ကြိုးစားလိုက်အုံးမယ်။

[code lang=”php”]
<?php
header("Content-Type: text/xml; charset=utf-8");
$url="https://www.google.com/tbproxy/spell?lang=en";
$text = urldecode("mystary");

$body = ‘<?xml version="1.0" encoding="utf-8" ?>’;
$body .= ‘<spellrequest textalreadyclipped="0" ignoredups="1" ignoredigits="1" ignoreallcaps="1">’;
$body .= ‘<text>’.$text.'</text>’;
$body .= ‘</spellrequest>’;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($ch);
curl_close($ch);

print $contents;
?>
[/code]

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.