Coder Social home page Coder Social logo

Comments (4)

asherber avatar asherber commented on July 18, 2024 1

Understood, thanks. I guess this issue page will always be here, in case anyone else is in the same boat!

from phpsmug.

lildude avatar lildude commented on July 18, 2024

Wow!! I've not looked at the old code in ages 😄

Your code looks good, but the problem isn't your code, it's with phpSmug - all the API urls are hardcoded to http and these have all been changed on the SmugMug side to redirect to https. Unfortunately, this results in invalid signatures etc and the old version of phpSmug doesn't handle this well.

The fix is to change all the URLs to use https:

diff --git a/phpSmug.php b/phpSmug.php
index 716d22a..d7d95e8 100644
--- a/phpSmug.php
+++ b/phpSmug.php
@@ -369,7 +369,7 @@ class phpSmug {
 		if ( ( strpos( $command, 'login.with' ) || strpos( $command, 'Token' ) ) || ( $this->oauth_signature_method == 'PLAINTEXT' ) || $this->secure ) {
 			$endpoint = "https://secure.smugmug.com/services/api/php/{$this->APIVer}/";
 		} else {
-			$endpoint = "http://api.smugmug.com/services/api/php/{$this->APIVer}/";
+			$endpoint = "https://api.smugmug.com/services/api/php/{$this->APIVer}/";
 			if ( ( isset( $this->SessionID ) && is_null( $this->SessionID ) ) && ( !strpos( $command, 'login.anonymously' ) ) && !$this->OAuthSecret ) {
 				throw new PhpSmugException( 'Not authenticated. No Session ID or OAuth Token.  Please login or provide an OAuth token.' );
 			}
@@ -655,7 +655,7 @@ class phpSmug {
 		if ( $this->loginType == 'authd' ) {
 			$upload_req->setHeader( 'X-Smug-SessionID', $this->SessionID );
 		} else {
-			$upload_req->setHeader( 'Authorization', 'OAuth realm="http://api.smugmug.com/",'
+			$upload_req->setHeader( 'Authorization', 'OAuth realm="https://api.smugmug.com/",'
 				.'oauth_consumer_key="'.$this->APIKey.'",'
 				.'oauth_token="'.$this->oauth_token.'",'
 				.'oauth_signature_method="'.$this->oauth_signature_method.'",'
@@ -678,7 +678,7 @@ class phpSmug {
 
 		//$proto = ( $this->oauth_signature_method == 'PLAINTEXT' || $this->secure ) ? 'https' : 'http';	// No secure uploads at this time.
 		//$upload_req->setURL( $proto . '://upload.smugmug.com/'.$args['FileName'] );
-		$upload_req->setURL( 'http://upload.smugmug.com/'.$args['FileName'] );
+		$upload_req->setURL( 'https://upload.smugmug.com/'.$args['FileName'] );
 		$upload_req->setBody( $data );
 
         //Send Requests
@@ -722,6 +722,7 @@ class phpSmug {
 
 		if ( $this->OAuthSecret ) {
 			$sig = $this->generate_signature( $method, $args );
+
 			$oauth_params = array (
 				'oauth_version'             => '1.0',
 				'oauth_nonce'               => $this->oauth_nonce,
@@ -825,9 +826,9 @@ class phpSmug {
 			} else if ( $apicall == 'Upload' ) {
 				//$proto = ( $this->oauth_signature_method == 'PLAINTEXT' || $this->secure ) ? 'https' : 'http';
 				//$endpoint = $proto . '://upload.smugmug.com/'.$apiargs['FileName'];	// No support for secure uploads yet
-				$endpoint = 'http://upload.smugmug.com/'.$apiargs['FileName'];
+				$endpoint = 'https://upload.smugmug.com/'.$apiargs['FileName'];
 			} else {
-				$endpoint = "http://api.smugmug.com/services/api/php/{$this->APIVer}/";
+				$endpoint = "https://api.smugmug.com/services/api/php/{$this->APIVer}/";
 			}
 
 			if ( is_null( $apicall ) ) {

from phpsmug.

asherber avatar asherber commented on July 18, 2024

Brilliant! Thanks so much for the quick response -- that's got things working.

I've made the changes locally, but do you think it might be worth an official release of 3.5.1?

from phpsmug.

lildude avatar lildude commented on July 18, 2024

I've made the changes locally, but do you think it might be worth an official release of 3.5.1?

I'm a bit reluctant to as the code is soooo old and ugly I'd really prefer peeps not use it TBH 😊

from phpsmug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.