티스토리 뷰
SMS 전송시 주소가 긴 링크를 줄이기 위해서 nShortURL 서비스를 사용해 보았습니다.
네이버 클라우드 플랫폼 > 서비스 > Application Server > nShortURL > 이용신청하기 버튼 클릭
https://www.ncloud.com/product/applicationService/nShortUrl
NAVER CLOUD PLATFORM
cloud computing services for corporations, IaaS, PaaS, SaaS, with Global region and Security Technology Certification
www.ncloud.com
콘솔 로그인 후 "+ Application 등록"
저장을 하면 App 리스트에 추가됩니다.
추가된 App 이름에 인증정보 버튼을 클릭하면 아래와 같은 창이 뜨는데
Client ID, Client Secret 정보로 호출 할 수 있습니다.
이제 호출 할 준비가 완료되었다면 Client ID, Client Secret를 사용하여 테스트를 해볼 수 있습니다.
https://api.ncloud-docs.com/docs/ai-naver-nshorturl-shorturl
shorturl - nShortURL
api.ncloud-docs.com
JavaScript 예제를 참고하여 아래와 같이 함수를 만들었습니다.
function req_shorturl(client_id, client_secret, orgUrl) {
console.log(client_id)
console.log(client_secret)
console.log(orgUrl)
var api_url = 'https://naveropenapi.apigw.ntruss.com/util/v1/shorturl';
var options = {
url: api_url+"?url="+orgUrl ,
headers: { 'X-NCP-APIGW-API-KEY-ID': client_id, 'X-NCP-APIGW-API-KEY': client_secret },
};
return new Promise(resolve=>{
request.get(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
//res.writeHead(200, { 'Content-Type': 'text/json;charset=utf-8' });
//res.end(body);
console.log(body)
let json = JSON.parse(body)
// console.log(json.result.url)
resolve(json.result.url)
} else {
//res.status(response.statusCode).end();
console.log('error = ' + response.statusCode);
resolve(query)
}
});
})
}
* 참고로 전송할 JSON 데이터중 url은 아래와 같이 api_url+"?url="+orgUrl 형태로 넣었습니다.
https://naveropenapi.apigw.ntruss.com/util/v1/shorturl?url=변경할주소
* 응답
{
"message":"ok",
"result": {
"hash":"GyvykVAu",
"url":"https://me2.do/GyvykVAu",
"orgUrl":"http://d2.naver.com/helloworld/4874130"
}
,"code":"200"
}
'개발 > API' 카테고리의 다른 글
네이버 SMS API (0) | 2022.04.11 |
---|
- Total
- Today
- Yesterday
- usbipd attach
- raspberrypi serial
- Shell Script
- 루미니
- clearTimeout
- artik710
- viewDidLoad()
- whose view is not in the window hierarchy
- Nginx #NodeJS #웹서버 #포트포워딩 #웹호스팅 #백엔드개발 #웹개발 #웹프로젝트 #서버관리 #웹애플리케이션
- action bar
- ProgressBar
- 어바니엘
- sms
- wsl usb mount
- 다트 플러터
- wsl lsblk
- viewDidAppear()
- Bad mode in Synchronous Abort handler detected
- SHORT URL
- USB Mass Storage
- Naver Cloud Platform
- Dart Flutter
- Window Status Bar
- AlertDialog
- setTimeout
- sms api
- 롯데캐슬
- Android Bar Color
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |