140) { $end = 140-(strlen($url)+1); $message = substr($message, 0, $end); $message = $message . ' ' . $url; } else { $message = $message . ' ' . $url; } $note = array('note[body]' => $message); curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password); curl_setopt($ch, CURLOPT_URL, 'http://brightkite.com/places/' . $place . '/notes.json'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $note); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $response = curl_exec($ch); curl_close($ch); $json = json_decode($response, TRUE); } } function shorturl ($url) { global $login, $apikey; $data['version'] = '2.0.1'; $data['longUrl'] = $url; $data['login'] = $login; $data['apiKey'] = $apikey; $data['format'] = 'json'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://api.bit.ly/shorten'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $response = curl_exec($ch); curl_close($ch); $json = json_decode($response, TRUE); return $json['results'][$url]['shortUrl']; } ?>