function pushToTwitter() { $post = grabPost(); $shortLink = shortenUrl(get_permalink($post->ID)); $ckey = get_option('tw_consumer_key'); $csecret = get_option('tw_consumer_secret'); $atoken = get_option('tw_access_token'); $asecret = get_option('tw_access_secret'); # Make our post to twitter based on our post content $twitterObj = new EpiTwitter($ckey, $csecret, $atoken, $asecret); $twitterObj->useAsynchronous(); $status = $twitterObj->post('/statuses/update.json', array('status' => trimPostForTwitter($post, $shortLink))); }
public function getIndex() { $profile = Profile::firstOrCreate(['user_id' => Auth::id()]); if ($profile && $profile->isActive == 1) { return redirect('/profile/index/' . $profile->id); } return redirect()->action('HomeController@getGameOver'); if ($profile->shortLink == "") { $profile->user_id = Auth::id(); $profile->shortLink = shortenUrl($_ENV['BASE_FB_URL'] . 'profile/index/' . $profile->id); } $profile->save(); $data = array('selectedPage' => 2); return view('register.index', $data); }
function postToTwitter($title) { $full = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $short = shortenUrl($full); $status = $title . '' . $short; return 'http://twitter.com/?status=' . urlencode($status); }
function getSavingsDiffTestnames($bCss, $testname1, $testname2) { $query = "select testnameid from spritemetestnames where testname = '{$testname1}';"; $testnameid1 = doSimpleQuery($query); $query = "select testnameid from spritemetestnames where testname = '{$testname2}';"; $testnameid2 = doSimpleQuery($query); if (!testnameid1 || !$testnameid2) { return; } $query1 = "select createdate, url, id, sd from spritemesavings where testnameid={$testnameid1} group by url;"; $result1 = doQuery($query1); $sHtml = ""; if ($bCss) { $sHtml .= <<<OUTPUT <style> .savingstable TH { padding: 0; color: #333; backgmyround: #CCC; font-weight: bold; } .savingstable TD { padding: 2px 8px 2px 8px; color: #333; backgmyround: #FFF; } TD.surl { padding-right: 0; } TD.sreqs { text-align: right; padding-right: 16px; padding-left: 0; } TD.ssize { text-align: right; padding-right: 8px; } TH.ssize { padding-left: 8px; padding-right: 8px; } TD.avg { backgmyround: #FFF; font-weight: bold; text-decoration: none; border-bottom: 1px solid; } </style> OUTPUT; } $sHtml .= "<table class=savingstable border=0 cellspacing=0 cellpadding=0>\n" . "<tr> <th></th> <th></th> <th class=sreqs>requests<br>eliminated</th> <th class=ssize>bytes<br>saved</th> <th class=sreqs>requests<br>eliminated</th> <th class=ssize>bytes<br>saved</th> </tr>\n"; $cntr = 0; $totalImages1 = 0; $totalDelta1 = 0; $totalImages2 = 0; $totalDelta2 = 0; $sRows = ""; while ($row1 = mysql_fetch_assoc($result1)) { $url = $row1['url']; $id1 = $row1['id']; $sd1 = $row1['sd']; $query2 = "select createdate, url, id, sd from spritemesavings where testnameid={$testnameid2} and url='{$url}' limit 1;"; $result2 = doQuery($query2); $url2 = ""; $id2 = $sd2 = 0; while ($row2 = mysql_fetch_assoc($result2)) { $url2 = $row2['url']; // use this as a flag $id2 = $row2['id']; $sd2 = $row2['sd']; break; } mysql_free_result($result2); if ($url2) { $sRows .= "<tr>" . "<td class=sdate>" . date("H:i", $row1['createdate']) . "</td>" . "<td class=surl><a class=ahover href='" . $row1['url'] . "' target='_blank'>" . shortenUrl($url) . "</a></td>" . "<td class=sreqs>{$id1}</td>" . "<td class=ssize>" . myround($sd1 / 1000) . " K</td>" . "<td class=sreqs style='" . ($id2 > $id1 ? "color: #0A0" : ($id2 < $id1 ? "color: #C00" : "")) . "'>{$id2}</td>" . "<td class=ssize style='" . ($sd2 > $sd1 ? "color: #0A0" : ($sd2 < $sd1 ? "color: #C00" : "")) . "'>" . myround($sd2 / 1000) . " K</td>" . "</tr>\n"; $cntr++; $totalImages1 += $id1; $totalDelta1 += $sd1; $totalImages2 += $id2; $totalDelta2 += $sd2; } } mysql_free_result($result1); if ($cntr) { $sHtml .= "<tr>" . "<td class=avg></td>" . "<td class=avg style='text-align: right;'>AVERAGE SAVINGS</td>" . "<td class='sreqs avg'>" . intval($totalImages1 / $cntr + 0.5) . "</td>" . "<td class='ssize avg'>" . intval($totalDelta1 / ($cntr * 1000) + 0.5) . " K</td>" . "<td class='sreqs avg'>" . intval($totalImages2 / $cntr + 0.5) . "</td>" . "<td class='ssize avg'>" . intval($totalDelta2 / ($cntr * 1000) + 0.5) . " K</td>" . "</tr>\n" . $sRows . "<tr> <th></th> <th></th> <th class=sreqs>requests<br>eliminated</th> <th class=ssize>bytes<br>saved</th> <th class=sreqs>requests<br>eliminated</th> <th class=ssize>bytes<br>saved</th> </tr>\n"; } $sHtml .= "</table>\n"; return $sHtml; }
} echo "</tr>\n"; // MySQL Table $sRows = ""; $iRow = 0; $gFirstStart = 0; $page = pageFromWPT($wptid, $wptrun); $aResources = $page['resources']; foreach ($aResources as $resource) { if (!$gFirstStart) { $gFirstStart = intval($resource['startedDateTime']); } $iRow++; $sRow = "<tr" . ($iRow % 2 == 0 ? " class=odd" : "") . ">"; $sRow .= "<td class='tdnum '>{$iRow}</td> "; $sRow .= "<td class='nobr ' style='font-size: 0.9em;'><a href='" . $resource['url'] . "'>" . shortenUrl($resource['url']) . "</a></td> "; for ($i = 0; $i < $len; $i++) { $column = $columns[$i]; if ('Req#' != $column['name'] && 'URL' != $column['name']) { $class = array_key_exists('class', $column) ? $column['class'] : "tdnum"; $suffix = array_key_exists('suffix', $column) ? $column['suffix'] : ""; $hidden = array_key_exists('hidden', $column) ? $column['hidden'] : ""; $sRow .= tdStat($resource, $column['dbName'], $suffix, $class, $hidden); } } $sRows .= $sRow; } echo $sRows; ?> </table>
<?php require_once dirname(__FILE__) . "/lib/TwitterOAuth.php"; function shortenUrl($url) { return file_get_contents("http://is.gd/create.php?format=simple&url=" . urlencode($url)); } $config = parse_ini_file('config.ini', true); $payload = getPayload(); $message = $payload->message; $message .= "\n"; $message .= shortenUrl($payload->url); $connection = new TwitterOAuth($config['twitter']['consumer_key'], $config['twitter']['consumer_secret'], $config['twitter']['oauth_token'], $config['twitter']['oauth_secret']); $content = $connection->get('account/verify_credentials'); $status = $connection->post('statuses/update', array('status' => $message)); print_r($status); # You can see posted message at https://twitter.com/#!/WorkerPHP