function add() { // Insert meal into database and get array $id = $this->meals_model->insert_meal($_POST); $meal = $this->meals_model->get_meal($id); // Generate tiny URL $this->load->helper('bitly_helper'); $bitly = new Bitly(); $bitly->set('nomealpoints', 'R_cffca0da875cf25106cfeb75291148a5'); $url = $bitly->shorten(site_url("/meal/" . $id)); // Add tiny URL to DB for future access $this->meals_model->set_url($id, $url); // Tweet it $tweet = meal_to_english($meal) . " " . $url['url']; $this->load->helper('twitter_helper'); if ($meal->private == false) { $this->load->library('twitter'); $this->twitter->auth('', ''); $this->twitter->update($tweet); } // Output $this->load->view('header', $message['message'] = $tweet); $this->load->view('admin_view'); $this->load->view('footer'); }
public function shorten($url) { $shortUrl = false; $bitly = new Bitly(null, null, eZINI::instance('nxcsocialnetworks.ini')->variable('LinkShortenHandlerBitly', 'GenericAccessToken')); try { $response = $bitly->shorten($url); $responseUrl = $response['url']; if ($responseUrl != '') { $shortUrl = $responseUrl; } } catch (Exception $e) { // Catch any API errors here } eZDebug::writeDebug("Shortened {$url} to {$shortUrl}", __METHOD__); return $shortUrl; }
function insert_meal($vars) { // inserts meal into db and returns confirmation message if ($vars['start'] != "") { $vars['start'] = date('Y-m-d H:i:s', strtotime($vars['start'])); } else { $vars['start'] = NULL; } if ($vars['end'] != "") { $vars['end'] = date('Y-m-d H:i:s', strtotime($vars['end'])); } else { $vars['end'] = NULL; } $this->db->insert('meals', $vars); $first_id = $this->db->insert_id(); if ($vars['repeat'] == 1) { while (strtotime($vars['start']) < 1273017600 - 604800) { // TOFIX: Hard coded May 5, 2010 if ($vars['start'] != NULL) { $vars['start'] = date('Y-m-d H:i:s', strtotime($vars['start']) + 604800); } // add a week if ($vars['end'] != NULL) { $vars['end'] = date('Y-m-d H:i:s', strtotime($vars['end']) + 604800); } $this->db->insert('meals', $vars); // This is repeated in the controller for the first instance // Generate tiny URL $this->load->helper('bitly_helper'); $bitly = new Bitly(); $bitly->set('nomealpoints', 'R_cffca0da875cf25106cfeb75291148a5'); $url = $bitly->shorten(site_url("/meal/" . $this->db->insert_id())); // Add tiny URL to DB for future access $this->meals_model->set_url($this->db->insert_id(), $url); } } return $first_id; }
<form class="appnitro"> <div class="form_description"> <h2><a href="http://remboursemoi.fr">Rembourse moi</a></h2> <p>Les bons comptes font les bons amis alors restons amis.</p> </div> </form> <div id="pay_description"> <p id="share"> Copie/Colle cette adresse à tes amis<br/> <img src="arrow-down.png" style="height:50px;margin-top:20px"><br/> <form> <?php $url = 'http://remboursemoi.fr/pay.php?email=' . urlencode($_GET['email']) . '&name=' . urlencode($_GET['name']) . '&amount=' . urlencode($_GET['amount']) . '¢=' . urlencode($_GET['cent']) . '&qte=' . urlencode($qte); require 'lib/bitly.php'; $bt = new Bitly('nazab', 'R_17a95912a5e8e7bd464b88c0f8236376'); $results = $bt->shorten($url, 'j.mp'); $short_url = 'http://j.mp/' . $results['hash']; ?> <input readonly="readonly" id="urltoshare" type="text" value="<?php echo $short_url; ?> " style="font-size:20px;width:280px;"/> </form><br/><br/>pour te faire rembourser.<br/><br/>Merci ! </p> <?php $stmt = $dbh->prepare("INSERT INTO `remboursemoi_request` (`rmb_name`,`rmb_email`,`rmb_amount`) values (?,?,?)"); try { $stmt->execute(array($_GET['name'], $_GET['email'], $_GET['amount'] . '.' . $_GET['cent'])); } catch (PDOExecption $e) { $dbh->rollback(); die("Error!: " . $e->getMessage() . "</br>");
foreach ($tags as $tag) { $tr = trim($tag); DB::execute('insert into blog_tag (id) values (?)', $tr); DB::execute('insert into blog_post_tag (tag_id, post_id) values (?, ?)', $tr, $p->id); } } require_once 'apps/blog/lib/Filters.php'; // autopost if ($autopost) { if ($autopost_pom) { $pom = new Pingomatic(); $pom->post($appconf['Blog']['title'], 'http://' . $_SERVER['HTTP_HOST'] . '/blog'); } if ($autopost_tw && !empty($appconf['Twitter']['username']) && !empty($appconf['Twitter']['password'])) { $b = new Bitly(); $short = $b->shorten('http://' . $_SERVER['HTTP_HOST'] . '/blog/post/' . $p->id . '/' . URLify::filter($p->title)); $t = new twitter(); $t->username = $appconf['Twitter']['username']; $t->password = $appconf['Twitter']['password']; $t->update($p->title . ' ' . $short); } } // reset blog rss cache $memcache->delete('blog_rss'); $_POST['page'] = 'blog/post/' . $p->id . '/' . URLify::filter($p->title); $lock->remove(); $this->hook('blog/edit', $_POST); $this->redirect('/blog/admin'); } $page->title = 'An Error Occurred'; echo 'Error Message: ' . $p->error;
<?php require_once 'include/config.php'; require_once 'include/bitly.php'; require_once 'twitter/twitteroauth/twitteroauth.php'; $recording_url = $_REQUEST['RecordingUrl']; $transcription_status = $_REQUEST['TranscriptionStatus']; $transcription_text = $_REQUEST['TranscriptionText']; if ($transcription_status === 'completed') { $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET); $bitly = new Bitly(BITLY_USERNAME, BITLY_API_KEY); $bitly_result = $bitly->shorten($recording_url . '.mp3'); // In case the transcription engine couldn't pick anything up if ($transcription_text == '(blank)') { $transcription_text = 'Hear recording: '; } // Okay, this is a little awkward to explain, but it's basically the max // length of a tweet, minus the length of the bit.ly link, minus the // length of the hashtag, minus 4 (for the spaces between all the // information). That gets us the number of characters left over for // the actual body of the tweet: // // 140 (max length of tweet) - strlen([bitly link] + ' ' + [hashtag length]) - 4 [for the spaces] $characters_left = 140 - strlen($bitly_result['url'] . ' ' . HASHTAG) - 4; $response = $connection->post('statuses/update', array('status' => truncate(stripslashes($transcription_text), $characters_left, '...') . ' ' . $bitly_result['url'] . ' ' . HASHTAG)); } // From http://www.php.net/manual/en/function.substr-replace.php#33736 function truncate($string, $max = 50, $rep = '') { if (strlen($string) > $max) { $leave = $max - strlen($rep);
} </style> </head> <body> <?php require_once 'lib/bitly.v3.class.php'; include 'config.php'; $urls = array('http://u.opposeto.com/eSLwEP', 'http://u.opposeto.com/hAKSbX'); $bitly = new Bitly($login, $apiKey); //print_r($bitly->clicksByMinute('http://u.opposeto.com/eSLwEP')); //print_r($bitly->clicksByDay('http://u.opposeto.com/eSLwEP')); if ($bitly->isProDomain('u.opposeto.com')) { echo '<p>This domain is pro!</p>'; } // this line generates error INVALID_URI if (!$bitly->shorten('http:/\\yahoo.com')) { echo '<div class="error">' . $bitly->getError() . '</div>'; } echo $bitly->shortenSingle('http://aerodromes.eu'); $data = $bitly->expand('dT0uqL'); echo '<p>' . $data[0]->long_url . '</p>'; $data = $bitly->lookup(array('http://aerodromes.eu', 'http://google.com')); if (!$data) { echo 'Error: ' . $bitly->getErrorCode() . ' "' . $bitly->getError() . '"'; } foreach ($data as $rowObj) { // check if found if (empty($rowObj->error)) { $url = $rowObj->short_url; $title = $bitly->getTitle($url) or trigger_error('Error: ' . $bitly->getErrorCode()); echo '<h1><a href="' . $url . '">' . $title . '</a></h1>';
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', 'WelcomeController@index'); Route::get('home', 'HomeController@index'); Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']); Route::get('/phone', function () { echo app('Smartphone'); }); Route::get('/shorten', function () { $responce = Bitly::shorten("http://google.com/"); echo $responce['data']['url']; });
function theContent($content) { $doc = phpQuery::newDocumentHTML($content); phpQuery::selectDocument($doc); foreach (pq('a') as $link) { $linkurl = pq($link)->attr('href'); $linkHostname = $this->getUrlHostname($linkurl); if ($linkHostname != FALSE) { if (!in_array($linkHostname, $this->blockedDomains)) { $linkHash = md5($linkurl); $query = "SELECT * FROM {$this->tableBitlyExternal} WHERE id='{$linkHash}'LIMIT 1;"; $linkData = $this->db->get_row($query, ARRAY_A); if (empty($linkData)) { $bitly = new Bitly($this->bitlyUsername, $this->bitlyApikey); $shortURL = $bitly->shorten($linkurl); $shortURLData = get_object_vars($bitly->getData()); if (!empty($shortURLData)) { $linkData = array('id' => $linkHash, 'url' => $linkurl, 'short_url' => $shortURLData['shortUrl'], 'hash' => $shortURLData['userHash'], 'created' => current_time('mysql')); $this->db->insert($this->tableBitlyExternal, $linkData); } } if (!empty($linkData)) { pq($link)->attr('href', $linkData['short_url']); } } } } return $doc->htmlOuter(); }
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('welcome'); }); Route::get('/home', function () { return 'Welcome Home!'; }); Route::get('/phone', function () { return Response::view('smartphone', ['smartPhone' => app('SmartPhone')]); }); Route::get('/gravatar', function () { return Response::view('gravatar', ['image' => Gravatar::get('*****@*****.**')]); }); Route::get('/shorten', function () { var_dump(Bitly::shorten('http://academy.binary-studio.com/#/user/hometaskinfo?id=5592d539c200e4d84feb2863')); });
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('welcome'); }); Route::get('/phone', ['as' => 'phone', function () { $smartphone = app()->make('Smartphone'); // dd($smartphone); return Response::view('smartphone', ['sm_name' => $smartphone->name, 'hw' => $smartphone->hardware]); }]); Route::get('/shorten', ['as' => 'shorten', function () { // dd( Bitly::shorten('http://google.com/') ); return Response::view('bitly', ['link' => Bitly::shorten('http://google.com/')['data']['url']]); }]);
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('welcome'); }); Route::get('/smartphone', function () { echo app()->make('Smartphone'); }); Route::get('/shorten', function () { return Response::view('shorten', ['link' => Bitly::shorten('http://focusenglish.com/dialogues/work/keepthatinmind.html')['data']['url']]); });