마이크로소프트 빙 번역기 라이브러리입니다.
<?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 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 401 |
|
1년 전 | 2335 | |
| 400 |
|
1년 전 | 1386 | |
| 399 | 1년 전 | 2772 | ||
| 398 | 1년 전 | 869 | ||
| 397 |
|
1년 전 | 2746 | |
| 396 | 1년 전 | 1336 | ||
| 395 | 1년 전 | 735 | ||
| 394 | 1년 전 | 452 | ||
| 393 | 1년 전 | 1012 | ||
| 392 |
다케미카코
|
1년 전 | 2654 | |
| 391 |
|
1년 전 | 806 | |
| 390 |
사노라가노라
|
1년 전 | 1051 | |
| 389 | 1년 전 | 504 | ||
| 388 |
|
1년 전 | 85436 | |
| 387 | 1년 전 | 823 | ||
| 386 | 1년 전 | 2519 | ||
| 385 | 2년 전 | 829 | ||
| 384 | 2년 전 | 1848 | ||
| 383 |
|
2년 전 | 1875 | |
| 382 | 2년 전 | 1427 | ||
| 381 | 2년 전 | 2579 | ||
| 380 |
|
2년 전 | 2129 | |
| 379 |
e4uhack
|
2년 전 | 2073 | |
| 378 |
|
2년 전 | 1066 | |
| 377 |
|
2년 전 | 1381 | |
| 376 | 2년 전 | 1211 | ||
| 375 |
|
2년 전 | 2236 | |
| 374 |
페이투페이
|
2년 전 | 1727 | |
| 373 |
|
2년 전 | 1454 | |
| 372 | 2년 전 | 1235 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기