- Модуль: socialservices
- Путь к файлу: ~/bitrix/modules/socialservices/classes/general/twitter.php
- Класс: CTwitterInterface
- Вызов: CTwitterInterface::SendTwit
public function SendTwit($socServUserId, $message, $messageId)
{
$isSetOauthKeys = true;
if(!$this->token || !$this->tokenSecret)
$isSetOauthKeys = self::SetOauthKeys($socServUserId);
if($isSetOauthKeys === false)
{
CSocServMessage::Delete($messageId);
return false;
}
if(mb_strlen($message) > 139)
$message = mb_substr($message, 0, 137)."...";
if(!defined("BX_UTF"))
$message = CharsetConverter::ConvertCharset($message, LANG_CHARSET, "utf-8");
$arParams = array_merge($this->GetDefParams(), array(
"oauth_token" => $this->token,
"status"=> $message,
));
$arParams["oauth_signature"] = urlencode($this->BuildSignature($this->GetSignatureString($arParams, $this::POST_URL)));
$arHeaders = array(
"Authorization" => 'OAuth oauth_consumer_key="'.$arParams["oauth_consumer_key"].'", oauth_nonce="'.$arParams["oauth_nonce"].'", oauth_signature="'.$arParams["oauth_signature"].'", oauth_signature_method="HMAC-SHA1", oauth_timestamp="'.$arParams["oauth_timestamp"].'", oauth_token="'.$this->token.'", oauth_version="1.0"',
);
$arPost = array("status"=> $message);
$result = @CHTTP::sPostHeader($this::POST_URL, $arPost, $arHeaders, $this->httpTimeout);
if($result !== false)
{
if(!defined("BX_UTF"))
$result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET);
return CUtil::JsObjectToPhp($result);
}
else
return false;
}