Beispiel #1
0
 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');
 }
 /**
  * Handles the request when being returned to the AuthManager plugin.
  *
  * @param CakeRequest $request
  *
  * @return bool
  */
 public function authenticateUser($request)
 {
     if (!array_key_exists('code', $request->query)) {
         return false;
     }
     $accessTokenData = $this->_Bitly->getAccessTokenData($request->query['code'], $this->_getCallbackUrl(MediaPlatform::BITLY));
     if (empty($accessTokenData)) {
         return false;
     }
     return $this->_saveUser($accessTokenData['login'], $accessTokenData['access_token'], MediaPlatform::BITLY);
 }
 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;
 }
Beispiel #4
0
 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;
 }
/**
 * Cron to process all of the posts that don't have bitly urls
 */
function bitly_process_posts()
{
    global $wpdb;
    // get 100 published posts that don't have a bitly url
    $query = "\n\t\tSELECT {$wpdb->posts}.ID\n\t\tFROM {$wpdb->posts}\n\t\tWHERE NOT EXISTS (\n\t\t\tSELECT ID\n\t\t\tFROM {$wpdb->postmeta}\n\t\t\tWHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id\n\t\t\tAND {$wpdb->postmeta}.meta_key = 'bitly_url'\n\t\t)\n\t\tAND ( {$wpdb->posts}.post_type = 'post' OR {$wpdb->posts}.post_type = 'page' )\n\t\tAND ( {$wpdb->posts}.post_status = 'publish' )\n\t\tGROUP BY {$wpdb->posts}.ID\n\t\tORDER BY {$wpdb->posts}.post_date DESC\n\t\tLIMIT 0, 100\n\t\t";
    $posts = $wpdb->get_results($query);
    if ($posts) {
        // process these posts
        foreach ($posts as $p) {
            Bitly::generate_bitly_url($p->ID);
        }
    } else {
        // kill our scheduled event
        add_option('bitly_processed', 1);
        wp_clear_scheduled_hook('bitly_hourly_hook');
    }
}
Beispiel #6
0
Blog: http://bitly.blogspot.com/
http://bitly.googlecode.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
function errorHandler($errno, $errstr, $errfile, $errline)
{
    header('Content-Type: text/plain; charset="utf-8"');
    $ret = array("errorCode" => 10001, "errorMessage" => $errstr, "statusCode" => "ERROR");
    echo json_encode($ret);
    exit;
}
$oldErrorHandler = set_error_handler('errorHandler');
require_once 'config.php';
require_once 'lib/bitly.class.php';
$bitly = new Bitly($login, $apiKey);
$action = $_POST['action'];
$url = $_POST['url'];
if ($bitly->validAction($action)) {
    echo $bitly->{$action}($url);
} else {
    echo $bitly->error();
}
 public static function load()
 {
     $bitly = Bitly::factory();
     //	Event::add('system.display', array('Bitly', 'shorten_text'));
 }
<?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);
Beispiel #9
0
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
    <title>Test</title>
</head>
<body>
<?php 
require_once 'lib/bitly.class.php';
include 'config.php';
$bitly = new Bitly($login, $apiKey);
$bitly->setReturnFormat('xml');
try {
    $bitly->error();
} catch (Exception $e) {
    echo '<div>' . $e->getMessage() . '</div>';
}
$url = $bitly->shortenSingle('http://www.ruslanas.com');
//$bitly->setReturnFormat('xml');
//echo $bitly->stats($url);
//exit;
// line below generates error
try {
    $bitly->getThumbnail();
} catch (Exception $e) {
    echo '<div>' . $e->getMessage() . '</div>';
}
$bitly->getInfoArray($url);
$bitly->getStatsArray($url);
echo '<h1>' . $bitly->getTitle() . '</h1>';
echo $bitly->getClicks() . ' clicks<br/>';
echo '<img src="' . $bitly->getThumbnail('medium') . '"/>';
Beispiel #10
0
<?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']]);
});
Beispiel #11
0
<?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']]);
}]);
Beispiel #12
0
         $tags = explode(',', $_POST['tags']);
         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';
Beispiel #13
0
function expandBitly($url)
{
    // get host name from URL
    preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
    $host = $matches[1];
    // get last two segments of host name
    preg_match('/[^.]+\\.[^.]+$/', $host, $matches);
    if ($matches[0] == 'bit.ly') {
        $bitly = new Bitly('o_19kpvsso1r', 'R_bb9f3f8d2aa62705fdc5750866f11176');
        $url = $bitly->expand($url);
    }
    return $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();
 }
function getShortUrl($longUrl)
{
    $bitly = new Bitly();
    $loginUsername = "******";
    $apiKey = "R_3619371f50c30a66315d1454eb046c2a";
    $bitly->setAuthentication($loginUsername, $apiKey);
    $shortUrl = $bitly->getShortURL($longUrl);
    return $shortUrl;
}
Beispiel #16
0
    // Wordpress has loaded
    function wp_loaded()
    {
        if (is_admin()) {
            add_action('admin_menu', 'bitly_admin_setup');
            add_filter('plugin_action_links', 'bitly_service_action_link', 10, 2);
        } else {
            // include jquery
            wp_enqueue_script('jquery');
            // include our js script
            wp_enqueue_script('bitly-js', plugins_url('/js/bitly-client.js', __FILE__));
        }
    }
}
// start
$bitly = new Bitly();
if ($oathToken = bitly_settings('oauthToken')) {
    $bitly->oauth($oathToken);
}
// require after $bitly has been defined so we can access statistics
if ($bitly->hasCurl()) {
    require_once 'bitly-widget.php';
}
/**
 * Loads the settings once and allows the input of the specific field the user would
 * like to show.
 *
 * @since 1.0.0
 */
function bitly_settings($option = '')
{
<?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'));
});
Beispiel #18
0
 private function bitly_expand($url = null)
 {
     $bitly = new Bitly('inorout', 'R_11acbfd4019e1d133a8dd8ebb339da03');
     return $bitly->expandSingle($url);
 }
Beispiel #19
0
		<h1>Remboursement entre amis</h1>
		<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']) . '&cent=' . 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();
Beispiel #20
0
<?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'];
});
Beispiel #21
0
            width: 100%;
        }
        table td {
            border: 1px solid;
        }
        .error {
            color: red;
        }
    </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() . '"';
Beispiel #22
0
 function getShortened($url)
 {
     include 'config.php';
     $bitly = new Bitly($login, $apiKey);
     return $bitly->shortenSingle($url);
 }