This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _json_encode( $data ) { | |
| if( is_array($data) || is_object($data) ) { | |
| $islist = is_array($data) && ( empty($data) || array_keys($data) === range(0,count($data)-1) ); | |
| if( $islist ) { | |
| $json = '[' . implode(',', array_map('__json_encode', $data) ) . ']'; | |
| } else { | |
| $items = Array(); | |
| foreach( $data as $key => $value ) { | |
| $items[] = __json_encode("$key") . ':' . __json_encode($value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function shortenUrl($longUrl){ | |
| if(!function_exists('curl_init')) { | |
| die ("Curl PHP package not installed\n"); | |
| } | |
| $BASEURL = "https://www.googleapis.com/urlshortener/"; | |
| $VERSION = "v1"; | |
| $SERVICE = "url"; | |
| $CONTENT_TYPE = "Content-Type: application/json"; |