마이크로소프트 빙 번역기 라이브러리입니다.
<?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 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 431 | 2개월 전 | 130 | ||
| 430 | 2개월 전 | 162 | ||
| 429 | 2개월 전 | 190 | ||
| 428 |
선택과집중
|
2개월 전 | 235 | |
| 427 |
선택과집중
|
2개월 전 | 386 | |
| 426 |
비버팩토리
|
3개월 전 | 358 | |
| 425 |
선택과집중
|
3개월 전 | 263 | |
| 424 |
선택과집중
|
3개월 전 | 392 | |
| 423 |
선택과집중
|
3개월 전 | 364 | |
| 422 |
선택과집중
|
3개월 전 | 330 | |
| 421 |
선택과집중
|
3개월 전 | 382 | |
| 420 | 4개월 전 | 420 | ||
| 419 |
선택과집중
|
4개월 전 | 361 | |
| 418 |
세르반데스
|
4개월 전 | 329 | |
| 417 |
선택과집중
|
4개월 전 | 416 | |
| 416 |
선택과집중
|
4개월 전 | 329 | |
| 415 |
선택과집중
|
4개월 전 | 362 | |
| 414 |
선택과집중
|
5개월 전 | 377 | |
| 413 |
선택과집중
|
5개월 전 | 462 | |
| 412 |
선택과집중
|
6개월 전 | 405 | |
| 411 |
선택과집중
|
6개월 전 | 313 | |
| 410 |
다케미카코
|
8개월 전 | 829 | |
| 409 |
다케미카코
|
8개월 전 | 582 | |
| 408 | 8개월 전 | 566 | ||
| 407 |
|
10개월 전 | 924 | |
| 406 | 11개월 전 | 1016 | ||
| 405 |
|
11개월 전 | 556 | |
| 404 | 1년 전 | 1271 | ||
| 403 | 1년 전 | 742 | ||
| 402 | 1년 전 | 776 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기