2026, 새로운 도약을 시작합니다.

마이크로소프트 빙 번역기 라이브러리입니다.

<?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. 끗
|

댓글 2개

좋은 정보 감사합니다 .!! 시간날때 사용해보겠습니다. ~~ 복받으세요 ~

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

그누보드5 팁자료실

번호 제목 글쓴이 날짜 조회
공지 3년 전 조회 4,598
2741 4일 전 조회 124
2740 5일 전 조회 112
2739 1주 전 조회 212
2738 1주 전 조회 218
2737 1주 전 조회 182
2736 2주 전 조회 281
2735 3주 전 조회 286
2734 3주 전 조회 264
2733 1개월 전 조회 266
2732 1개월 전 조회 301
2731 1개월 전 조회 268
2730 1개월 전 조회 227
2729 1개월 전 조회 359
2728 1개월 전 조회 245
2727 1개월 전 조회 422
2726 1개월 전 조회 257
2725 1개월 전 조회 332
2724 1개월 전 조회 361
2723 1개월 전 조회 267
2722 1개월 전 조회 300
2721 1개월 전 조회 213
2720 2개월 전 조회 304
2719 2개월 전 조회 307
2718 2개월 전 조회 202
2717 2개월 전 조회 337
2716 2개월 전 조회 202
2715 2개월 전 조회 313
2714 2개월 전 조회 273
2713 2개월 전 조회 377
2712 2개월 전 조회 289
🐛 버그신고