테스트 사이트 - 개발 중인 베타 버전입니다

짧은 주소 bit.ly api 사용 어떻게 해요?? 채택완료

존재하는 9년 전 조회 4,616

이전 자료 검색해 보니 

 

이렇든데... 안되네요!!

 

어떤곳 수정 하면 되나요 ??

</p><p><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><? </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">  </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">$bo_url = "$trackback_url"; </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">$shorturl = getSmallLink($bo_url); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">//짧은 주소($shorturl); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">function getSmallLink($longurl){ </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">// Bit.ly </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">$key_url = </span><a href="<a href="http://api.bit.ly/shorten?version=2.0.1&longUrl=" target="_blank" rel="noopener noreferrer">http://api.bit.ly/shorten?version=2.0.1&longUrl=</a>" target="_blank" style="text-decoration: none; color: rgb(63, 67, 71); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><a href="http://api.bit.ly/shorten?version=2.0.1&longUrl=" target="_blank" rel="noopener noreferrer">http://api.bit.ly/shorten?version=2.0.1&longUrl=</a></a><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">$longurl&login=발급받은 아이디&apiKey=발급받은 키&format=json&history=1; </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">$s = curl_init(); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">curl_setopt($s,CURLOPT_URL, $key_url); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">curl_setopt($s,CURLOPT_</span><span style="font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; color: red; background-color: yellow;">HEA</span><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">DER,false); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">curl_setopt($s,CURLOPT_RETURNTRANSFER,1); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">$result = curl_exec($s); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">curl_close( $s ); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">$obj = json_decode($result, true); </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">return $obj["results"]["$longurl"]["shortUrl"]; </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">} </span><br style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);"><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">?> </span> </p><p><span style="color: rgb(34, 34, 34); font-family: NanumGothicWeb, 나눔고딕, Verdana, Tahoma; font-size: 12px; line-height: 18px; background-color: rgb(255, 255, 255);">

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

답변 2개

채택된 답변
+20 포인트
9년 전

서버에 curl이라는게 설치가 안되어 있으면 작동하지 않습니다.

서버에 curl를 직접 설치하거나 호스팅 회사에 curl 설치를 요청하세요.

로그인 후 평가할 수 있습니다

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

9년 전

아이디와 키는 발급 받으신건가요??

소스에 보시면 발급받은 아이디와 키 입력하는 부분 있습니다. 이 부분에 발급받은 것을 넣으시면 됩니다. 

로그인 후 평가할 수 있습니다

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

답변을 작성하려면 로그인이 필요합니다.

로그인