TWTMORE on DABR


edit config.php

taro ini

// twtmore api key
define(‘TWTMORE_API_KEY’, ‘ISI_DENGAN_API_TWTMORE_KAMU’);

Pada file common/twitter.php, cari function twitter_update() {

menambahkan coding dibawah ini SEBELUM if ($status) {

$callback_key = false;
if (mb_strlen($status, ‘utf-8′) > 140) {
$reply_to_id = null;
if (is_numeric((string) $_POST['in_reply_to_id'])) {
$reply_to_id = (string) $_POST['in_reply_to_id'];
}
$response = post_twtmore_tweet(user_current_username(), $status, $reply_to_id);
if (!$response) {
theme(‘error’, "

Long tweet error

An unexpected error occured while posting to twtmore. Please try again.


“);
twitter_refresh($_POST[‘from’] ? $_POST[‘from’] : ”);
return;
}

$tatus = $response->tweet->short_content;
$callback_key = $response->callback_key;
}

masih di dalam funtion yg sama, tambahkan coding di bawah ini SESUDAH $b =  twitter_process($request, $post_data);

if ($callback_key) {
post_twtmore_callback($callback_key, $b->id_str);
}

kemudian tambahkan junga coding functions di dalam file common/twitter.php tersebut, terserah di taro di bagian mana, asal tidak di dalam function yg lain, taruh saja di bagian paling bawah sebelum tanda ?>

function post_twtmore_tweet($username, $tweet, $reply_to_tweet_id = null)
{

// Formulate the request
$request = array(
‘apikey’ => TWTMORE_API_KEY,
‘user’ => $username,
‘tweet’ => $tweet
);

// If reply
if ($reply_to_tweet_id)
{
$request['reply_to_tweet'] = $reply_to_tweet_id;
}

// Create CURL
$url = ‘http://api.twtmore.com/v3/shorten’;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

// Execute CURL
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

// Close CURL
curl_close($ch);

// Check we have a % 200 HTTP status code, and the JSON decodes ok
if ($code == 200 && ($resp = json_decode($response)))
{
return $resp;
}

// There was an error
return false;
}

function post_twtmore_callback($callback_key, $twitter_id)
{
$request = array(
‘apikey’ => TWTMORE_API_KEY,
‘key’ => $callback_key,
‘status_id’ => $twitter_id
);

$url = ‘http://api.twtmore.com/v3/callback’;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
}

Visit Another Twitter Client ==>> www.MTSocial.com

Advertisements

About ABoedMan

Arief Budiman | B 1987 PML (VirgoBoy) | ab0806in:ab0112st | single | GUNDAR '12 | YUPTA1 '06 | NEVATA '03 | SDCIPON4 '00 | 7CEEC55F | Email: mail2aboed-arief@yahoo.co.id | http://www.bisnisplus.com
This entry was posted in dabr and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s