Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Twitter Login Handler
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 18 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Login;
|
||||
@@ -28,6 +27,11 @@ class _Twitter extends LoginAbstract
|
||||
*/
|
||||
public static $icon = 'twitter';
|
||||
|
||||
/**
|
||||
* @brief Logo
|
||||
*/
|
||||
public static $logo = 'Twitter';
|
||||
|
||||
/**
|
||||
* @brief Share Service
|
||||
*/
|
||||
@@ -64,7 +68,7 @@ class _Twitter extends LoginAbstract
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->denied ) )
|
||||
{
|
||||
throw new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::INTERNAL_ERROR );
|
||||
throw new \IPS\Login\Exception( 'denied_oauth', \IPS\Login\Exception::INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
try
|
||||
@@ -218,8 +222,20 @@ class _Twitter extends LoginAbstract
|
||||
unset( $params[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
$signatureBaseString = mb_strtoupper( $method ) . '&' . rawurlencode( $url ) . '&' . rawurlencode( http_build_query( $OAuthAuthorization, NULL, '&' ) ) . ( count( $params ) ? ( rawurlencode( '&' ) . rawurlencode( http_build_query( $params, NULL, NULL, PHP_QUERY_RFC3986 ) ) ) : '' );
|
||||
|
||||
/* Media handling needs specific handling as a multipart form and not a signed param list */
|
||||
$media = NULL;
|
||||
if ( isset( $params['media'] ) )
|
||||
{
|
||||
$media = $params['media'];
|
||||
unset( $params['media'] );
|
||||
}
|
||||
|
||||
/* All keys sent in the signature must be in alphabetical order, that includes oAuth keys and user sent params */
|
||||
$allKeys = array_merge( $OAuthAuthorization, $params );
|
||||
ksort( $allKeys );
|
||||
|
||||
$signatureBaseString = mb_strtoupper( $method ) . '&' . rawurlencode( $url ) . '&' . rawurlencode( http_build_query( $allKeys, NULL, '&', PHP_QUERY_RFC3986 ) );
|
||||
$signingKey = rawurlencode( $this->settings['consumer_secret'] ) . '&' . rawurlencode( $secret ?: $token );
|
||||
$OAuthAuthorizationEncoded = array();
|
||||
foreach ( $OAuthAuthorization as $k => $v )
|
||||
@@ -233,9 +249,26 @@ class _Twitter extends LoginAbstract
|
||||
}
|
||||
}
|
||||
$OAuthAuthorizationHeader = 'OAuth ' . implode( ', ', $OAuthAuthorizationEncoded );
|
||||
|
||||
$headers = array( 'Authorization' => $OAuthAuthorizationHeader );
|
||||
|
||||
/* Build the multipart media request */
|
||||
if ( $media )
|
||||
{
|
||||
$mimeBoundary = sha1( microtime() );
|
||||
$headers['Content-Type'] = 'multipart/form-data; boundary=' . $mimeBoundary;
|
||||
|
||||
$data = '--' . $mimeBoundary . "\r\n";
|
||||
$data .= 'Content-Disposition: form-data; name="media";' . "\r\n";
|
||||
$data .= 'Content-Type: application/octet-stream' . "\r\n" . "\r\n";
|
||||
$data .= $media . "\r\n";
|
||||
$data .= '--' . $mimeBoundary . '--' . "\r\n" . "\r\n";
|
||||
|
||||
$params = $data;
|
||||
}
|
||||
|
||||
/* Send the request */
|
||||
return \IPS\Http\Url::external( $url )->request()->setHeaders( array( 'Authorization' => $OAuthAuthorizationHeader ) )->$method( $params );
|
||||
return \IPS\Http\Url::external( $url )->request()->setHeaders( $headers )->$method( $params );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user