마이크로소프트 빙 번역기 라이브러리입니다.
<?php
class BingTransrator
{
protected $_token;
public function getToken() {
$postData = array (
'client_id' => '클라이언트 아이디',
'client_secret' => '클라이언트 시크릿키',
'grant_type' => 'client_credentials',
'scope' => 'http://api.microsofttranslator.com'
);
$ch = curl_init("https://datamarket.accesscontrol.windows.net/v2/OAuth2-13");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$result = json_decode($result);
if (!is_object($result) || empty($result->access_token)) {
die("Access Token Error");
}
$this->_token = $result->access_token;
}
// 바꿀문자, 기존언어, 변경할언어
public function translate($content, $languageFrom = 'en', $languageTo = 'ko') {
$postData = array(
'text' => $content,
'from' => $languageFrom,
'to' => $languageTo,
'contentType' => 'text/plain'
);
$ch = curl_init('http://api.microsofttranslator.com/V2/Http.svc/Translate?' . http_build_query($postData));
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->_token));
$translation = curl_exec($ch);
return trim($translation);
}
}
/* 사용법
include_once(G5_LIB_PATH.'/translate.bing.lib.php');
$bing = new BingTransrator();
$bing->getToken();
echo htmlspecialchars_decode($bing->translate('변경할 문자', '기존언어', '변경할언어'));
?>
빙번역은 찾아도 없길래 올려봅니다 ''
( 구글번역은 유료라서....하앍...)
1. https://datamarket.azure.com/account 에서 아이디 생성
2. https://datamarket.azure.com/dataset/bing/microsofttranslator 에서 0원짜리 2만 캐릭터를 구매한다 [결제없음]
3. https://datamarket.azure.com/developer/applications/register 에서 어플을 하나 생성한다.
(주의 : Redirect URI는 http://를 포함해서 본인의 사이트를 써도돼고, http://www.google.com 을 써도 됨
단 http:// 무조건 포함)
4. 위의 라이브러리를 그누보드 라이브러리 폴더에 translate.bing.lib.php 저장한다.
5. translate.bing.lib.php 저장한 파일을 열어서 client_id에는 위에서 생성한 cliend_id 복붙, client_secret도 마찬가지로 복붙
6. 번역할 페이지 가서 include 해준 후 사용
7. 끗
class BingTransrator
{
protected $_token;
public function getToken() {
$postData = array (
'client_id' => '클라이언트 아이디',
'client_secret' => '클라이언트 시크릿키',
'grant_type' => 'client_credentials',
'scope' => 'http://api.microsofttranslator.com'
);
$ch = curl_init("https://datamarket.accesscontrol.windows.net/v2/OAuth2-13");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$result = json_decode($result);
if (!is_object($result) || empty($result->access_token)) {
die("Access Token Error");
}
$this->_token = $result->access_token;
}
// 바꿀문자, 기존언어, 변경할언어
public function translate($content, $languageFrom = 'en', $languageTo = 'ko') {
$postData = array(
'text' => $content,
'from' => $languageFrom,
'to' => $languageTo,
'contentType' => 'text/plain'
);
$ch = curl_init('http://api.microsofttranslator.com/V2/Http.svc/Translate?' . http_build_query($postData));
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->_token));
$translation = curl_exec($ch);
return trim($translation);
}
}
/* 사용법
include_once(G5_LIB_PATH.'/translate.bing.lib.php');
$bing = new BingTransrator();
$bing->getToken();
echo htmlspecialchars_decode($bing->translate('변경할 문자', '기존언어', '변경할언어'));
?>
빙번역은 찾아도 없길래 올려봅니다 ''
( 구글번역은 유료라서....하앍...)
1. https://datamarket.azure.com/account 에서 아이디 생성
2. https://datamarket.azure.com/dataset/bing/microsofttranslator 에서 0원짜리 2만 캐릭터를 구매한다 [결제없음]
3. https://datamarket.azure.com/developer/applications/register 에서 어플을 하나 생성한다.
(주의 : Redirect URI는 http://를 포함해서 본인의 사이트를 써도돼고, http://www.google.com 을 써도 됨
단 http:// 무조건 포함)
4. 위의 라이브러리를 그누보드 라이브러리 폴더에 translate.bing.lib.php 저장한다.
5. translate.bing.lib.php 저장한 파일을 열어서 client_id에는 위에서 생성한 cliend_id 복붙, client_secret도 마찬가지로 복붙
6. 번역할 페이지 가서 include 해준 후 사용
7. 끗
댓글 3개
프로그래머7
9년 전
ms 번역은 잘됩니까? 구글번역은 별로라서요
9년 전
덤앤더머에요 ㅎㅎ
프로그래머7
9년 전
그렇군요 ^^ 감사합니다
게시판 목록
영카트5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 341 | 4년 전 | 4058 | ||
| 340 | 4년 전 | 3371 | ||
| 339 | 4년 전 | 3199 | ||
| 338 | 4년 전 | 3762 | ||
| 337 | 4년 전 | 4118 | ||
| 336 | 4년 전 | 2797 | ||
| 335 |
|
4년 전 | 2690 | |
| 334 | 4년 전 | 2247 | ||
| 333 |
|
4년 전 | 2308 | |
| 332 |
|
4년 전 | 3146 | |
| 331 |
|
4년 전 | 3792 | |
| 330 | 4년 전 | 2202 | ||
| 329 | 4년 전 | 3694 | ||
| 328 | 4년 전 | 2161 | ||
| 327 | 4년 전 | 2723 | ||
| 326 | 4년 전 | 2581 | ||
| 325 | 4년 전 | 5023 | ||
| 324 | 4년 전 | 2190 | ||
| 323 |
파이브스톤즈
|
4년 전 | 3015 | |
| 322 | 4년 전 | 2514 | ||
| 321 | 4년 전 | 2546 | ||
| 320 | 5년 전 | 1877 | ||
| 319 | 5년 전 | 2559 | ||
| 318 | 5년 전 | 4104 | ||
| 317 | 5년 전 | 4102 | ||
| 316 | 5년 전 | 2646 | ||
| 315 | 5년 전 | 3825 | ||
| 314 | 5년 전 | 3636 | ||
| 313 |
|
5년 전 | 1638 | |
| 312 | 5년 전 | 4149 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기