Fitur TweetLonger Kanvaso untuk Dabr (Twitter Client)


Pertama, download dan install dabr package dari sini
Kedua, Register dan dapatkan Kanvaso API dari http://api.kanvaso.com/1/register.php
Ketiga, tambahkan kode d bawah ini pada bagian config.php pada file dabr mu

define('KANVASO_API_KEY', 'Kanvaso_API_Kamu');


Keempat, masuk ke file /common/twitter.php pada file dabr mu
cari code if ($status) {
kemudian tambahkan kode d bawah ini

// shrink the status if it exceeds Twitter’s limit 140
if(mb_strlen($status, ‘utf-8’) > 140)
$status = handle_long_tweet($status);

Terakhir masih d file yang sama tambahkan fungsi :

function handle_long_tweet($status) {
require_once(‘OAuth.php’);

$header = array(
‘X-Auth-Service-Provider: https://api.twitter.com/1/account/verify_credentials.json’,
‘X-Verify-Credentials-Authorization: OAuth realm="http://api.twitter.com/"’
);
$consumer = new OAuthConsumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
$sha1_method = new OAuthSignatureMethod_HMAC_SHA1();

// user’s token
list($oauth_token, $oauth_token_secret) = explode(‘|’, $GLOBALS[‘user’][‘password’]);
$token = new OAuthConsumer($oauth_token, $oauth_token_secret);

// Generate all the OAuth parameters needed
$signingURL = ‘https://api.twitter.com/1/account/verify_credentials.json’;
$request = OAuthRequest::from_consumer_and_token($consumer, $token, ‘GET’, $signingURL, array());
$request->sign_request($sha1_method, $consumer, $token);

$header[1] .= ", oauth_consumer_key=\"" . $request->get_parameter(‘oauth_consumer_key’) . "\"";
$header[1] .= ", oauth_signature_method=\"" . $request->get_parameter(‘oauth_signature_method’) ."\"";
$header[1] .= ", oauth_token=\"" . $request->get_parameter(‘oauth_token’) ."\"";
$header[1] .= ", oauth_timestamp=\"" . $request->get_parameter(‘oauth_timestamp’) ."\"";
$header[1] .= ", oauth_nonce=\"" . $request->get_parameter(‘oauth_nonce’) ."\"";
$header[1] .= ", oauth_version=\"" . $request->get_parameter(‘oauth_version’) ."\"";
$header[1] .= ", oauth_signature=\"" . urlencode($request->get_parameter(‘oauth_signature’)) ."\"";

$url = ‘http://api.kanvaso.com/1/update.php’;

$ch = curl_init();

$contents = array(‘text’=>urlencode($status),
‘api_key’=>KANVASO_API_KEY,
‘format’=>’json’);

foreach($contents as $key=>$value) {
$fields .= $key . ‘=’ . $value . ‘&’;
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

$respond = curl_exec($ch);

$response_info = curl_getinfo($ch);

curl_close($ch);

$result = json_decode($respond);
if($result->status == ‘success’)
return $result->text;
else
return $result->text;
}

Jangan lupa kunjungi & gunakan Twitter Client dari kami di alamat www.imorv.comūüôā

@fays_lee

3 Tanggapan

  1. boleh minta dabr editan kamu gk admin >?

  2. saya udah ikutin semuanya .
    malah syntax error unexpected ‘>’

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: