Selasa, 11 September 2012

0 Fitur TweetLonger WriteLonger untuk Dabr (Twitter Client)

Pertama, cari fungsi twitter_update() di file /common/twitter.php
kemudian cari baian: if ($status) {
dan sebelem: $request = API_URL.’statuses/update.json’;
tambahkan code di bawah ini

if (mb_strlen($status, ‘utf-8′) > 140) {
$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/"’
);
require_once(‘OAuth.php’);
$consumer = new OAuthConsumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
$sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
list($oauth_token, $oauth_token_secret) = explode(‘|’, $GLOBALS['user']['password']);
$token = new OAuthConsumer($oauth_token, $oauth_token_secret);
$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’)) ."\"";
$longtweetlink = ‘http://api.writelonger.com/create.php’;
$contents = array(‘text’=>urlencode($status),
‘api_key’=>’WL_H52m239dvsd’,
‘format’=>’json’);
foreach($contents as $key=>$value) {
$fields .= $key . ‘=’ . $value . ‘&’;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, $longtweetlink);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$respond = curl_exec($ch);
$response_info = curl_getinfo($ch);
curl_close($ch);
$result = json_decode($respond);
$status = $result->text;
}
Jangan lupa kunjungi & gunakan Twitter Client dari kami di alamat www.imorv.com :)
@fays_ozunugt; 140) {
$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/"’
);
require_once(‘OAuth.php’);
$consumer = new OAuthConsumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
$sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
list($oauth_token, $oauth_token_secret) = explode(‘|’, $GLOBALS['user']['password']);
$token = new OAuthConsumer($oauth_token, $oauth_token_secret);
$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’)) ."\"";
$longtweetlink = ‘http://api.writelonger.com/create.php’;
$contents = array(‘text’=>urlencode($status),
‘api_key’=>’WL_H52m239dvsd’,
‘format’=>’json’);
foreach($contents as $key=>$value) {
$fields .= $key . ‘=’ . $value . ‘&’;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, $longtweetlink);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$respond = curl_exec($ch);
$response_info = curl_getinfo($ch);
curl_close($ch);
$result = json_decode($respond);
$status = $result->text;
}

0 Comments

Bagaimana Pendapat Anda ?