goo.gl short URL API 사용 > php

본문 바로가기
사이트 내 전체검색

php

goo.gl short URL API 사용

페이지 정보

작성자 서방님 댓글 0건 조회 121회 작성일 12-11-14 11:22

본문

구글 사이트를 참조합니다.
http://code.google.com/apis/urlshortener/v1/reference.html#method_urlshortener_url_insert  

2011년 3월 기준 위 링크의 API 를 참조했습니다.

function googl_short_url($long_url) {
//  global $googl_login, $googl_api_key;
    $googl_api_key = "API키값";
    $googl_url = "https://www.googleapis.com/urlshortener/v1/url";
    $post_url = $googl_url . "?key=" . $googl_api_key;
    $post_data = "{\"longUrl\": \"".$long_url."\"}";

    $response = file_post_contents_curl($post_url, $post_data)undefined;
    $obj = json_decode($response);
    $short_url = $obj->{'id'};

    return $short_url;


$long_url 값, 즉 URL 주소를 입력하면 ( 예) http://www.google.co.kr/intl/ko/about.html),
"http://goo.gl/tuaw2" 가 $short_url 이 됩니다.

댓글목록

등록된 댓글이 없습니다.

Total 612건 31 페이지
게시물 검색

회원로그인

접속자집계

오늘
246
어제
225
최대
1,347
전체
155,005
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.