Home » » Tweet artikel dengan mencantumkan shorten url bit.ly dengan php

Tweet artikel dengan mencantumkan shorten url bit.ly dengan php

Kali ini saya akan share cara membuat tweet artikel dengan mencantumkan shorten url bit.ly dengan php. Ini untuk mempersingkat tweet apabila url website Anda panjang, langsung saja Anda buat dulu fungsi php seperti dibawah ini.

<?php

function get_short_link($url) {

$bitly_login="Usernama Anda"; // username untuk login

$bitly_apikey="bit.ly API key Anda";



$api_call = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl=".$url."&login=".$bitly_login."&apiKey=".$bitly_apikey);



$bitlyinfo=json_decode(utf8_encode($api_call),true);



if ($bitlyinfo['errorCode']==0) {

return $bitlyinfo['results'][urldecode($url)]['shortUrl'];

} else {

return false;

}}

?>

Untuk variable $bitly_login dan $bitly_apikey atau yang saya beri tanda, Anda ganti dengan username dan api key Anda.
Untuk melihat api key Anda, setelah Anda login Anda masuk ke link ini https://bitly.com/a/your_api_key.
Membuat fungsinya sudah selesai sekarang tweet artikel atau link yang sedang Anda buka.
Untuk mengambil link yang sedang Anda buka bisa menggunakan $_SERVER['REQUEST_URI'].

$urlself =  str_replace(':', '%3A',

  str_replace('/', '%2F',

  str_replace('?', '%3F',

  str_replace('=', '%3D',

  str_replace('&', '%26',

    'http://www.hoqqi.com'.$_SERVER['REQUEST_URI'])))));

    

$shoturl = get_short_link($urlself);

    

$i++;

Sekarang pasang deh kode tweetnya pada setiap postingan Anda.

<a href="http://twitter.com/share"
class="twitter-share-button" data-text="<?php echo $shoturl;
?> " data-count="none" data-url="none" data-related="Judul Website Anda">Tweet</a><script
type="text/javascript"
src="http://platform.twitter.com/widgets.js"></script>

Nah selesai deh, Setiap postingan Anda pada tweet artikelnya akan menggunakan url shorten dari bit.ly secara otomatis.
Semoga bermanfaat.

pada setiap posting tweetnya telah menggunakan url shorten bit.ly

Related Posts

1 comment:

Blogger said...

Look at the way my acquaintance Wesley Virgin's autobiography begins with this SHOCKING AND CONTROVERSIAL video.

Wesley was in the army-and shortly after leaving-he revealed hidden, "SELF MIND CONTROL" secrets that the CIA and others used to get whatever they want.

THESE are the same secrets tons of celebrities (notably those who "became famous out of nowhere") and the greatest business people used to become rich and famous.

You probably know that you use less than 10% of your brain.

That's mostly because most of your BRAINPOWER is UNCONSCIOUS.

Maybe that thought has even occurred INSIDE OF YOUR very own head... as it did in my good friend Wesley Virgin's head 7 years back, while driving an unlicensed, garbage bucket of a car with a suspended license and $3.20 on his debit card.

"I'm very fed up with going through life paycheck to paycheck! When will I become successful?"

You've taken part in those thoughts, isn't it so?

Your own success story is waiting to be written. You just need to take a leap of faith in YOURSELF.

Take Action Now!

Post a Comment

 
Copyright © 2013. Information & Learning - All Rights Reserved
Template by Johny Template