if
(mb_strlen(
$status
,
'utf-8'
) > 140) {
$header
=
array
(
);
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
);
$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'
)) .
"\""
;
$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;
}