/*
* 1. Download and install dabr package from http://code.google.com/p/dabr/
* 2. Register and get Kanvaso API from http://api.kanvaso.com/1/register.php
* 3. Add following line into config.php file of dabr
*/
define(\'KANVASO_API_KEY\', \'your Kanvaso API key\');
/*
* 4. Insert following lines to twitter_update() function in /common/twitter.php
* at line 799 after:
* "$status = twitter_url_shorten(stripslashes(trim($_POST[\'status\'])));"
*/
// shrink the status if it exceeds Twitter\'s limit 140
if(mb_strlen($status, \'utf-8\') > 140)
$status = handle_long_tweet($status);
/*
* 5. Finally, at the end of the /common/twitter.php, copy and paste following function
*/
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;
}
//http://api.kanvaso.com/1/doc_update.php