Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+21 -20
View File
@@ -58,7 +58,7 @@ class _Twitter extends PromoteAbstract
{
if ( static::$twitter === NULL )
{
static::$twitter = \IPS\Login::getHandler('Twitter');
static::$twitter = \IPS\Login\Handler::findMethod('IPS\Login\Handler\Oauth1\Twitter');
}
return static::$twitter;
@@ -90,9 +90,10 @@ class _Twitter extends PromoteAbstract
/**
* Get name
*
* @param string|NULL $serviceId Specific page/group ID
* @return string
*/
public function getName()
public function getName( $serviceId=NULL )
{
return $this->settings['name'];
}
@@ -104,15 +105,8 @@ class _Twitter extends PromoteAbstract
*/
public function canPostToPage()
{
try
{
$this->twitter()->sendRequest( 'get', 'https://api.twitter.com/1.1/account/verify_credentials.json', array(), $this->settings['token'], $this->settings['secret'] )->decodeJson();
return TRUE;
}
catch ( \IPS\Http\Request\Exception $e ) { }
return FALSE;
$twitter = \IPS\Login\Handler::findMethod('IPS\Login\Handler\Oauth1\Twitter');
return $twitter->hasWritePermissions( $this->settings['token'], $this->settings['secret'] );
}
@@ -134,7 +128,7 @@ class _Twitter extends PromoteAbstract
$textToActuallyUse .= ' ' . $link;
}
if ( mb_strlen( $textToActuallyUse ) < 140 )
if ( mb_strlen( $textToActuallyUse ) < 280 )
{
/* Got any tags to add? */
if ( count( $this->settings['tags'] ) )
@@ -142,7 +136,7 @@ class _Twitter extends PromoteAbstract
if ( $this->settings['tags_method'] === 'trim' )
{
$urlLength = mb_strlen( $link ) + 2; // spaces either side
$left = 140 - $urlLength;
$left = 280 - $urlLength;
$tagLength = 0;
$tagString = '';
$useText = $text;
@@ -168,7 +162,7 @@ class _Twitter extends PromoteAbstract
{
$considerAddingThis = ' #' . $tag;
if ( mb_strlen( $textToActuallyUse . $considerAddingThis ) < 140 )
if ( mb_strlen( $textToActuallyUse . $considerAddingThis ) < 280 )
{
$textToActuallyUse .= $considerAddingThis;
}
@@ -185,7 +179,7 @@ class _Twitter extends PromoteAbstract
$return[] = \IPS\Theme::i()->getTemplate( 'promote' )->promoteDialogTwitterDuplicate();
}
$return[] = new \IPS\Helpers\Form\TextArea( 'promote_social_content_twitter', $textToActuallyUse, FALSE, array( 'maxLength' => 300, 'rows' => 3 ) );
$return[] = new \IPS\Helpers\Form\TextArea( 'promote_social_content_twitter', $textToActuallyUse, FALSE, array( 'maxLength' => 600, 'rows' => 3 ) );
return $return;
}
@@ -211,8 +205,8 @@ class _Twitter extends PromoteAbstract
/* Twitter can only have a max of 4 images */
if ( $done < 4 )
{
$this->response = $this->twitter()->sendRequest( 'post', 'https://upload.twitter.com/1.1/media/upload.json', array( 'media' => $photo->contents() ), $this->settings['token'], $this->settings['secret'] )->decodeJson();
$this->response = $this->twitter()->sendMedia( $photo->contents(), $this->settings['token'], $this->settings['secret'] );
if ( isset( $this->response['media_id_string'] ) )
{
$mediaIds[] = $this->response['media_id_string'];
@@ -241,7 +235,7 @@ class _Twitter extends PromoteAbstract
$send['media_ids'] = implode( ',', $mediaIds );
}
$this->response = $this->twitter()->sendRequest( 'post', "https://api.twitter.com/1.1/statuses/update.json", $send, $this->settings['token'], $this->settings['secret'] )->decodeJson();
$this->response = $this->twitter()->sendStatus( $send, $this->settings['token'], $this->settings['secret'] );
if ( isset( $this->response['id_str'] ) )
{
@@ -249,6 +243,13 @@ class _Twitter extends PromoteAbstract
}
else
{
/* Check for specific errors */
if ( isset( $this->response['error'] ) )
{
\IPS\Log::log( $this->response['error'], 'twitter' );
throw new \InvalidArgumentException( $this->response['error'] );
}
/* Check for non critical errors we don't need to flag as complete failures */
if ( isset( $this->response['errors'] ) )
{
@@ -272,14 +273,14 @@ class _Twitter extends PromoteAbstract
}
}
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('twitter_publish_exception') );
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->get('twitter_publish_exception') );
}
}
catch ( \Exception $e )
{
\IPS\Log::log( $e->getMessage(), 'twitter' );
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('twitter_publish_exception') );
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->get('twitter_publish_exception') );
}
}