本文整理汇总了PHP中make_bitly_url函数的典型用法代码示例。如果您正苦于以下问题:PHP make_bitly_url函数的具体用法?PHP make_bitly_url怎么用?PHP make_bitly_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_bitly_url函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_tweet
function create_tweet($title, $link, $twitter)
{
//#UniverseTee - Titre_raccourci_si_besoin : url_article Par @nom_du_compte
// short url
$short = make_bitly_url($link);
if (isset($twitter)) {
$message_without_title = '... : ' . $short . ' Par ' . $twitter;
} else {
$message_without_title = '... : ' . $short;
}
// 140
$short_title = split_to_chunks($message_without_title, $title);
if (count($short_title) == 1) {
$short_title = $short_title[0];
} else {
$short_title = $short_title[0] . '...';
}
if (isset($twitter)) {
$tweet = $short_title . ' : ' . $short . ' Par ' . $twitter;
} else {
$tweet = $short_title . ' : ' . $short;
}
return $tweet;
}
示例2: woo_short_url
function woo_short_url($url)
{
_deprecated_function(__FUNCTION__, '6.0.0', __('Shortlinks feature in WooDojo.', 'woothemes'));
$service = get_option('woo_url_shorten');
$bitlyapilogin = get_option('woo_bitly_api_login');
$bitlyapikey = get_option('woo_bitly_api_key');
if (isset($service)) {
switch ($service) {
case 'TinyURL':
$shorturl = getTinyUrl($url);
break;
case 'Bit.ly':
if (isset($bitlyapilogin) && isset($bitlyapikey) && $bitlyapilogin != '' && $bitlyapikey != '') {
$shorturl = make_bitly_url($url, $bitlyapilogin, $bitlyapikey, 'json');
} else {
$shorturl = getTinyUrl($url);
}
break;
case 'Off':
$shorturl = $url;
break;
default:
$shorturl = $url;
break;
}
} else {
$shorturl = $url;
}
return $shorturl;
}
示例3: urlencode
//create the URL
$bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login=' . $login . '&apiKey=' . $appkey . '&format=' . $format;
//get the url
//could also use cURL here
$response = file_get_contents($bitly);
//parse depending on desired format
if (strtolower($format) == 'json') {
$json = @json_decode($response, true);
return $json['results'][$url]['shortUrl'];
} else {
$xml = simplexml_load_string($response);
return 'http://bit.ly/' . $xml->results->nodeKeyVal->hash;
}
}
$camplink = 'https://leveque.newstorycharity.org/' . $getcampaigner['slug'];
$short = make_bitly_url($camplink, 'o_3l3tbfj5mo', 'R_779e61f639264d3ea0f263b56c22ab50', 'json');
// short link function ends here //
//** Email to donor starts here **//
$donorto = $getdonor['email'];
$donorsubject = 'Thank you for investing in Leveque!';
$donormsg = "<html>\n<head>\n<title>Thank you for investing in Leveque!</title>\n</head>\n<body>\n<p>Dear " . $getdonor['firstname'] . ",</p>\n\n<p>Thank you for your generous gift. We depend upon ongoing support from partners like you to continue bringing life transformation to every man, woman, and child in Haiti. Your faithful investment will provide a permanent block home for a family in need in the Leveque community! When their home is built we will send you photographs and a video of the life transformation your gift has provided.</p>\n\n<p>If you haven't done so already, <a href='mohhaiti.org/users/new?utm_source=trigger&utm_medium=email&utm_campaign=general+donation+form'>please register for a MyMOH account.</a> This account will allow you to view your gift history, receive updates, make a gift in the future and much more.</p>\n\n<p>Once again, thank you for your support!</p>\n\n<p>God bless you!</p>\n\n<p>The Mission of Hope, Haiti Team</p>\n</body>\n</html>";
$donorheaders = 'MIME-Version: 1.0' . "\r\n";
$donorheaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$donorheaders .= 'From: Mission of Hope<leveque@mohhaiti.org>' . "\r\n";
$campaignheaders .= 'Reply-To: leveque@mohhaiti.org' . "\r\n";
mail($donorto, $donorsubject, $donormsg, $donorheaders);
//** Email to donor ends here **//
//** Email to campaigner starts here **//
$campaignerto = $getcampaigner['email'];
$campaignersubject = $getdonor['firstname'] . ' Donated';
$campaignermsg = "<html>\n<head>\n<title>" . $getdonor['firstname'] . " Donated</title>\n</head>\n<body>\n<p>Hey " . $getcampaigner['name'] . " !</p>\n\n<p>You've received a \$" . $getdonor['amount'] . " donation to your campaign <i><a href='" . $short . "' target='_blank'>" . $getcampaigner['campaignsname'] . "</a></i> from " . $getdonor['firstname'] . ". </p>\n\n<p>Your hard work means a new story is being written and we thank you.</p> \n\n<p>Be sure to thank your supporter. Below is an easy template you can use and here's their email - " . $getdonor['email'] . "</p>\n\n<p>-- New Story Team</p>\n</body>\n</html>";
示例4: woo_short_url
function woo_short_url($url)
{
$service = get_option('woo_url_shorten');
$bitlyapilogin = get_option('woo_bitly_api_login');
$bitlyapikey = get_option('woo_bitly_api_key');
if (isset($service)) {
switch ($service) {
case 'TinyURL':
$shorturl = getTinyUrl($url);
break;
case 'Bit.ly':
if (isset($bitlyapilogin) && isset($bitlyapikey) && $bitlyapilogin != '' && $bitlyapikey != '') {
$shorturl = make_bitly_url($url, $bitlyapilogin, $bitlyapikey, 'json');
} else {
$shorturl = getTinyUrl($url);
}
break;
case 'Off':
$shorturl = $url;
break;
default:
$shorturl = $url;
break;
}
} else {
$shorturl = $url;
}
return $shorturl;
}
示例5: author_biography
</div>
</div>
</section>
<section class="single-body">
<div class="col-fixed col-fixed-left pull-left" style="height:1800px;">
<?php
echo author_biography();
?>
<div class="divider"></div>
<div id="sticky_sharing">
<h4 class="sharing">Social</h4>
<ul class="share">
<?php
$bitly = make_bitly_url($permalink);
$share_title = urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8'));
?>
<li class="social facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=<?php
echo $bitly;
?>
" data-shared="<?php
the_title();
?>
" data-social="Facebook" target="_blank"><i class="fa fa-facebook-square"></i>Share</a></li>
<li class="social twitter"><a href="https://twitter.com/share?text=<?php
echo $share_title;
?>
&url=<?php
echo $bitly;
示例6: compartirTwitter
function compartirTwitter($id)
{
$cadena = 'http://twitter.com/intent/tweet?url=' . make_bitly_url(get_permalink($id), 'json') . '&' . 'text=' . substr(obtenerExcerptCorto($id), 0, 105) . ' via @media_TIC';
return $cadena;
}
示例7: make_bitly_url
<?php
function make_bitly_url($url, $login, $appkey, $format = 'xml', $history = 1, $version = '2.0.1')
{
// Modified function originally from http://davidwalsh.name/bitly-php
//create the URL
$bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login=' . $login . '&apiKey=' . $appkey . '&format=' . $format . '&history=' . $history;
//get the url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $bitly . "?" . $param);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
//parse depending on desired format
if (strtolower($format) == 'json') {
$json = @json_decode($response, true);
return $json['results'][$url]['shortUrl'];
} else {
$xml = simplexml_load_string($response);
return 'http://bit.ly/' . $xml->results->nodeKeyVal->hash;
}
}
// end function make_bitly_url
header('Content-Type: application/json; charset=utf8');
print json_encode(make_bitly_url($_POST['url'], 'YOUR_BITLY_USERNAME', 'YOUR_BITLY_API_KEY', 'json'));
示例8: shorten
public function shorten($url)
{
return make_bitly_url($utl, 'fill me in');
}
示例9: array
<?php
include_once '/home/minecraft/server/bin/index_wp.php';
require_once '/var/www/bin/magpierss/rss_fetch.inc';
$feedurls = array("http://uncovery.me/feed/" => 'Blog Post', "http://uncovery.me/comments/feed/" => 'Comment', "http://uncovery.me/forums/feed/" => 'Forum Post');
foreach ($feedurls as $feedurl => $type) {
$rss = fetch_rss($feedurl);
//var_dump($rss);
// get only the first item
$items = array_slice($rss->items, 0, 1);
$current_items = array();
foreach ($items as $item) {
$url = $item['guid'];
$url = make_bitly_url($url);
/*$pos = strpos($url, '#post-');
if ($pos !== false) {
preg_match('/#post-([0-9]*)/', $url, $matches);
$id = $matches[1];
//$url = " http://uncovery.me/?p=$id";
}*/
$text = "New {$type}: {$item['title']} {$url} by {$item['dc']['creator']}";
//echo $text;
update_rss($text, $type);
}
}
function make_bitly_url($url, $format = 'xml', $version = '2.0.1')
{
$appkey = 'R_7885c7338712a9f1f6852a9bd0655b7b';
$login = 'uncovery';
//create the URL
$bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login=' . $login . '&apiKey=' . $appkey . '&format=' . $format;
示例10: fbogmeta_header
function fbogmeta_header()
{
global $post;
// encurtar a url
if (is_single() || is_page()) {
?>
<?php
//Check for post’s shortened URL. Used with twitter feedback.
if (get_post_meta($post->ID, "short_url", true) != "") {
//Short URL already exists, pull from post meta
$short_url = get_post_meta($post->ID, "short_url", true);
} else {
//No short URL has been made yet
$full_url = get_permalink();
$short_url = make_bitly_url($full_url, 'json');
//Save generated short url for future views
add_post_meta($post->ID, 'short_url', $short_url, true);
}
if (empty($short_url)) {
$short_url = $full_url;
}
?>
<!-- Open Graph Meta Tags for Facebook and LinkedIn Sharing !-->
<meta property="og:title" content="<?php
the_title();
?>
"/>
<meta property="og:url" content="<?php
echo $short_url;
?>
"/>
<?php
$fb_image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'index-image');
?>
<?php
if ($fb_image) {
?>
<meta property="og:image" content="<?php
echo $fb_image[0];
?>
" />
<?php
}
?>
<meta property="og:type" content="<?php
if (is_single() || is_page()) {
echo "article";
} else {
echo "website";
}
?>
" />
<meta property="og:site_name" content="<?php
bloginfo('name');
?>
"/>
<!-- End Open Graph Meta Tags !-->
<?php
} else {
?>
<?php
if (get_theme_mod('hemingway_logo')) {
?>
<meta property="og:image" content="<?php
echo esc_url(get_theme_mod('hemingway_logo'));
?>
" />
<?php
}
?>
<meta property="og:title" content="<?php
echo esc_attr(get_bloginfo('title'));
?>
" />
<meta property="og:description" content="<?php
echo esc_attr(get_bloginfo('description'));
?>
" />
<?php
}
}
示例11: urlencode
//create the URL
$bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login=' . $login . '&apiKey=' . $appkey . '&format=' . $format;
//get the url
//could also use cURL here
$response = file_get_contents($bitly);
//parse depending on desired format
if (strtolower($format) == 'json') {
$json = @json_decode($response, true);
return $json['results'][$url]['shortUrl'];
} else {
$xml = simplexml_load_string($response);
return 'http://bit.ly/' . $xml->results->nodeKeyVal->hash;
}
}
/* usage */
$short = make_bitly_url('http://leveque.newstorycharity.org', 'o_3l3tbfj5mo', 'R_779e61f639264d3ea0f263b56c22ab50', 'json');
echo 'The short URL is: ' . $short;
// returns: http://bit.ly/11Owun
exit;
$usersubject = 'New Story Login Details';
$usermsg = '<html>
<head>
<title>New Story Login Details</title>
</head>
<body>
<p>Hey envee !</p>
<p>Thankyou for creating campaign - <a target="_blank" href="https://newstorycharity.com/test-mail.php">aaaa</a>! and registering with New Story Charity. Below are your New Story login details:</p>
<p>Email: dddd</p>
<p>--Matthew</p>
</body>
</html>';
示例12: array
require_once 'send_tweet.php';
// get random ts post
$args = array('numberposts' => 12, 'orderby' => 'post_date');
$rand_posts = get_posts($args);
$rand_id = rand(0, 11);
$post = $rand_posts[$rand_id];
if (isset($post)) {
$title = __($post->post_title);
$punchline = __($post->post_content);
$category = get_the_category($post->ID);
$image = get_image_url($post->ID);
$author = "";
foreach ($category as $cat) {
$author .= " " . $cat->cat_name;
}
$url = make_bitly_url('http://www.universetee.com/fr/' . $post->post_name);
// 140
$tweet = 'Tshirt' . $author . ' - ' . $title . ' : ' . $url;
//send_tweet_image($tweet,$image);
send_tweet($tweet);
echo $tweet;
}
/* make a URL small */
function make_bitly_url($url)
{
//create the URL
return file_get_contents("http://tinyurl.com/api-create.php?url=" . $url);
}
/* split_to_chunks by John Hamelink 2010. This code is in the PUBLIC DOMAIN. */
function split_to_chunks($to, $text)
{