document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2.  * 1. Download and install dabr package from http://code.google.com/p/dabr/
  3.  * 2. Register and get Kanvaso API from http://api.kanvaso.com/1/register.php
  4.  * 3. Add following line into config.php file of dabr
  5.  */
  6. define(\'KANVASO_API_KEY\', \'your Kanvaso API key\');
  7.  
  8.  
  9. /*
  10.  * 4. Insert following lines to twitter_update() function in /common/twitter.php
  11.  *    at line 799 after:
  12.  *    "$status = twitter_url_shorten(stripslashes(trim($_POST[\'status\'])));"
  13.  */
  14.  
  15. // shrink the status if it exceeds Twitter\'s limit 140
  16. if(mb_strlen($status, \'utf-8\') > 140)
  17.   $status = handle_long_tweet($status);
  18.  
  19.  
  20. /*
  21.  * 5. Finally, at the end of the /common/twitter.php, copy and paste following function
  22.  */
  23. function handle_long_tweet($status) {
  24.   require_once(\'OAuth.php\');
  25.  
  26.   $header = array(
  27.                   \'X-Auth-Service-Provider: https://api.twitter.com/1/account/verify_credentials.json\',
  28.                   \'X-Verify-Credentials-Authorization: OAuth realm="http://api.twitter.com/"\'
  29.                   );
  30.   $consumer = new OAuthConsumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
  31.   $sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
  32.  
  33.   // user\'s token
  34.   list($oauth_token, $oauth_token_secret) = explode(\'|\', $GLOBALS[\'user\'][\'password\']);
  35.   $token = new OAuthConsumer($oauth_token, $oauth_token_secret);
  36.  
  37.   // Generate all the OAuth parameters needed
  38.   $signingURL = \'https://api.twitter.com/1/account/verify_credentials.json\';
  39.   $request = OAuthRequest::from_consumer_and_token($consumer, $token, \'GET\', $signingURL, array());
  40.   $request->sign_request($sha1_method, $consumer, $token);
  41.  
  42.   $header[1] .= ", oauth_consumer_key=\\"" . $request->get_parameter(\'oauth_consumer_key\') . "\\"";
  43.   $header[1] .= ", oauth_signature_method=\\"" . $request->get_parameter(\'oauth_signature_method\') ."\\"";
  44.   $header[1] .= ", oauth_token=\\"" . $request->get_parameter(\'oauth_token\') ."\\"";
  45.   $header[1] .= ", oauth_timestamp=\\"" . $request->get_parameter(\'oauth_timestamp\') ."\\"";
  46.   $header[1] .= ", oauth_nonce=\\"" . $request->get_parameter(\'oauth_nonce\') ."\\"";
  47.   $header[1] .= ", oauth_version=\\"" . $request->get_parameter(\'oauth_version\') ."\\"";
  48.   $header[1] .= ", oauth_signature=\\"" . urlencode($request->get_parameter(\'oauth_signature\')) ."\\"";
  49.  
  50.   $url = \'http://api.kanvaso.com/1/update.php\';
  51.  
  52.   $ch = curl_init();
  53.  
  54.   $contents = array(\'text\'=>urlencode($status),
  55.                     \'api_key\'=>KANVASO_API_KEY,
  56.                     \'format\'=>\'json\');
  57.  
  58.   foreach($contents as $key=>$value) {
  59.     $fields .= $key . \'=\' . $value . \'&\';
  60.   }
  61.   curl_setopt($ch, CURLOPT_URL, $url);
  62.   curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  63.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  64.   curl_setopt($ch, CURLOPT_POST, 1);
  65.   curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  66.  
  67.   $respond = curl_exec($ch);
  68.  
  69.   $response_info = curl_getinfo($ch);
  70.  
  71.   curl_close($ch);
  72.  
  73.   $result = json_decode($respond);
  74.   if($result->status == \'success\')
  75.     return $result->text;
  76.   else
  77.     return $result->text;
  78. }
  79.  
  80. //http://api.kanvaso.com/1/doc_update.php
  81.  
');