Coder Social home page Coder Social logo

lildude / phpsmug Goto Github PK

View Code? Open in Web Editor NEW
43.0 10.0 19.0 1.25 MB

:camera: phpSmug is a simple object orientated wrapper for the new SmugMug API v2, written in PHP.

Home Page: https://lildude.github.io/phpSmug

License: MIT License

PHP 100.00%
php php-library smugmug-api composer maintained

phpsmug's People

Contributors

dependabot[bot] avatar elcontraption avatar harikt avatar hvanoch avatar jacobfogg avatar lildude avatar nickturrietta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpsmug's Issues

phpSmug should provide a method that returns an OAuth signed URL for GET requests

Idea from David Parry @ Smugmug...

I took the liberty of changing one of your albums :)

I turned externals off on this gallery… [redacted]

So requesting any of those image URLs from another web server should fail without OAuth.

The idea I had to make it the most flexible was to have a function like signResource($url), > where you pass the image URL that you want to sign and the function returns the $url with all the OAuth parameters. You can then pass that off to curl, wget or embed it in an img tag.

As I understand this, this is essentially creating a method that returns a string for GET requests with all of the OAuth params included... like Appendix A.5.3 at http://oauth.net/core/1.0/

redirect to password protected album

I am looking for a bit of help and not on twitter. If this is in the wrong place, please let me know where best to direct my question.

We would like our clients to move from our client area (behind user name and password on our domain) into a password protected smugmug gallery located on a subdomain. phpSmug is helping with the api tremendously, but I cannot seem to get albums_browse to work (curl error 56). I am at a loss on how to figure out what is happening.

Question - how can I make the redirect into a password protected gallery occur using album browse (or if redirect is not possible, what more may be needed for the browse to work)?

Thank you.

PS - I should have mentioned that I am currently trying this in an anon session and can get the album info via albums_getInfo.

setToken problems using own account credentials

I've been dropped in a little at the deep end here, and am new to just about everything involved except for PHP, so please excuse me if I'm being daft. I'm trying to authenticate against my own account, I have no need to do so for other users' accounts, so am attempting to use setToken with the oauth token and secret provided under SmugMug's web interface (Settings -> Privacy -> Authorized Services -> Token) rather than going through the token request process. Is there some reason that should't work?

My code is extremely simple and initially looked like this:

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// This file is generated by Composer
require_once 'vendor/autoload.php';

// Optional, but definitely nice to have, options
$options = [
        'AppName' => 'My Test/1.0 (https://www.example.org)',
        ];
$client = new phpSmug\Client('MY API KEY', $options);
print "<br><b>Setting Token:</b><br>";
$client->setToken('MY OAUTH TOKEN', 'MY OAUTH SECRET');
# THIS IS THE POINT WHERE IT BREAKS TO START WITH
print "<br><b>Getting list of repositories:</b><br>";
$repositories = $client->get('user/MYUSERNAME!albums');
# THIS IS THE POINT WHERE IT BREAKS WITH SECRET IN OPTIONS
print_r($repositories);
...

That fails at the first point shown by my comments above, and gives me a:
"Fatal error: Uncaught exception 'phpSmug\Exception\InvalidArgumentException' with message 'An OAuthSecret is required for all SmugMug OAuth interactions.' in /var/www/other/smug/vendor/lildude/phpsmug/lib/phpSmug/Client.php:389 Stack trace: #0 /var/www/other/smug/index.php(19): phpSmug\Client->setToken('MY OAUTH TOKEN...', 'MY OAUTH SECRET...') #1 {main} thrown in /var/www/other/smug/vendor/lildude/phpsmug/lib/phpSmug/Client.php on line 389"

If I add 'OAuthSecret' => 'MY OAUTH SECRET' to options, the client seems to be instantiated OK, but it breaks at the second point shown by my comments, with::
"Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: GET https://api.smugmug.com/api/v2/user/MYUSERNAME!albums resulted in a 401 Unauthorized response: {"Code":401,"Message":"oauth_problem=signature_invalid&debug_sbs=GET&https%3A%2F%2Fapi.smugmug.com%2Fapi%2Fv2%2Fuser%2Fi (truncated...) ' in /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /var/www/other/smug/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /var/www/other/smug/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /var/www/other/smug/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleH in /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113"

I've tried to follow the phpsmug and smugmug API documentation with a dollop of common sense, but have clearly gone astray. Any help or hints would be appreciated.

Thanks,

Adrian

Reimplement caching

With the switch to using Guzzle in phpSmug 4.0.0, I ditched caching the responses.

I'd rather do this properly with a Guzzle middleware than the old hack.

Undefined offset in Client.php __call() caused by empty URI arguments

Hello,

When certain unusual URI queries are passed to phpSmug, we sometimes receive the following error:

PHP Notice: Undefined offset: 1 in /vendor/lildude/phpsmug/lib/phpSmug/Client.php on line 139

This is caused when contiguous '&' characters appear in the query statement, effectively creating empty arguments, as seen here between arg1 and arg2:

...?arg1=value1&&arg2=value2

The PHP notice can be corrected by stripping out these empty arguments, by inserting the following at line 137 in phpsmug/lib/phpSmug/Client.php, just before the foreach loop:
$pairs = array_diff($pairs,['']);

Here is the context:

# Cater for any args passed in via `?whatever=foo`
if (strpos($url, '?') !== false) {
  $pairs = explode('&', explode('?', $url)[1]);
  $pairs = array_diff($pairs,['']);   // remove empty args caused by adjacent &s in $url
  foreach ($pairs as $pair) {
    list($key, $value) = explode('=', $pair);
    $this->request_options['query'][$key] = $value;
  }
}

I'm sorry I can't formally fork and unit test this right now, although this fix is working in my project.

more examples?

Greetings,

I'm jumping into the space and was wondering if there is an example using phpSmug and pulling from a specific album?

Is this project abandoned?

I notice you've not merged a fairly important branch change into master, are you no longer maintaining this?

Access headers in response

I have a need to view the headers in the response from the SmugMug API.

Guzzle has a method for getting the response headers, but it does not appear to be implemented in phpSmug.

From the Guzzle docs:

You can retrieve headers from the response:

// Check if a header exists.
if ($response->hasHeader('Content-Length')) {
echo "It exists";
}

// Get a header from the response.
echo $response->getHeader('Content-Length')[0];

// Get all of the response headers.
foreach ($response->getHeaders() as $name => $values) {
echo $name . ': ' . implode(', ', $values) . "\r\n";
}

And on the same doc page, immediately following:

The body of a response can be retrieved using the getBody method. The body can be used as a string, cast to a string, or used as a stream like object.

$body = $response->getBody();
// Implicitly cast the body to a string and echo it
echo $body;

phpSmug exposes the body in its private function processResponse(), but does not expose the headers.

Undefined Property / and Class 'phpSmug\Client' not found

Hello,

As will become painfully clear, I am not very well-versed in APIs, so please be patient with me and assume the worst (as in, does he really not know how to do that? No. No, he doesn't.)

I just started trying to use the phpSmug example code and have run into two issues:

  1. Various Errors:

Notice: Undefined property: stdClass::$Album in /opt/bitnami/apps/wordpress/htdocs/smugmug/index2.php on line 54
Notice: Trying to get property 'Uris' of non-object in /opt/bitnami/apps/wordpress/htdocs/smugmug/index2.php on line 54
Notice: Trying to get property 'AlbumImages' of non-object in /opt/bitnami/apps/wordpress/htdocs/smugmug/index2.php on line 54
stdClass Object ( [Uri] => /api/v2/user/gktwvillage!albums?count=1 [Locator] => Album [LocatorType] => Objects [Pages] => stdClass Object ( [Total] => 0 [Start] => 1 [Count] => 0 [RequestedCount] => 1 [FirstPage] => /api/v2/user/gktwvillage!albums?count=1&start=1 [LastPage] => /api/v2/user/gktwvillage!albums?count=1&start=0 ) )
Notice: Undefined property: stdClass::$AlbumImage in /opt/bitnami/apps/wordpress/htdocs/smugmug/index2.php on line 57
Warning: Invalid argument supplied for foreach() in /opt/bitnami/apps/wordpress/htdocs/smugmug/index2.php on line 57

  1. After reading the transcript of someone else's issue on this forum, I thought that the reason for the above errors was that all of our albums were private; so, I took the answer provided to that user and attempted to use the oAuth example, where I get this error:

Fatal error: Uncaught Error: Class 'phpSmug\Client' not found in

Can you offer any suggestions as to how to fix this?

Thanks,
Matt

Caching re-stores data to the cache it's just pulled it from thus resulting in an updated timestamp on the cache (entry or file) and could potentially lead to stale cache data. This affects both DB and FS caching.

Caching re-stores data to the cache it's just pulled it from thus resulting in an updated timestamp on the cache (entry or file) and could potentially lead to stale cache data. This affects both DB and FS caching.

Reported by Aaron on 28 Aug '09

— Ticket #4 Migrated from http://phpSmug.com

list all folders

With API 2.0 on smugmug, I can't seem to find a way to list my folders (not Albums). My library at Smugmug is all folders on top, and gallerys below them. When I list albums, I only see some of my gallerys, not all. They used to call them gallerys not albums. I've figured out how to use the new phpsmug to get those albums, and list the photos inside, I'm just missing lots of them. Almost all my gallerys are public, so I'm not authenticating when using phpsmug. Thanks for any help.

Get client error code

Hello, in my attempt to create albums automatically, I have realized, that if the UrlName already exists, it directly does not return anything to me, but I skip the 409 client error, but without being object or anything.

How can I get this code to control it with an if?

My idea is that if it already exists, add a number to the UrlName using a function, and if that also exists, add 1 to the previous number. This part has already been solved, I lack control if it exists...

Thanks in advance!

image not displaying

My next issue seems to be an odd one. Using your sample login example php file, the result will not display the images. With a simple echo:

echo '';

It results int he HTML not finding the resource: "Failed to load resource: the server responded with a status of 404 (Not Found)"

When I copy/paste the URL and toss it in a new tab - I see the photo just fine.

Would this be a limitation of the API?

Problems with expansions

I'm having a couple of problems with expansions in v4.

  1. Since get() returns only the Response part, adding an _expand param doesn't seem to give any way of accessing the Expansions element. Should there be a $client->getExpansions() method? Or should any use of an _expand parameter silently add _expandmethod=inline?

  2. phpSmug doesn't seem to like multiple expansions. If I do get('user/[username]!albums?_expandmethod=inline&_expand=Node') I get the expected response, but if I do get('user/[username]!albums?_expandmethod=inline&_expand=Node,HighlightImage') I don't get either URI expanded. (Same results either using $options or specifying the query string in get().) Making the request from Postman does give the multiple expansion.

POST an Album

Hello, I'm trying to create an album for later upload images. My idea is that every user of my web has an own album, so they have to be created automatically.

The problem I have encountered is that when I put the POST method, it returns me this error: 400 Bad Request response: {"Options":{"Methods":["POST"],"ParameterDescription":{"Boolean":"For true return type true or 1, for false type false o (truncated...) (Error Code: 400)

In Live API from SmugMug, the same JSON and URL works correctly.

Here is my code:

$name = "Big Cats";
$urlName = "BigCats";

$option = array(
"AutoRename"=> false,
"CoverImageUri"=> null,
"Description"=> "",
"HideOwner"=> false,
"HighlightImageUri"=> null,
"Name"=> $name,
"Keywords"=> [],
"Password"=> "",
"PasswordHint"=> "",
"Privacy"=> 1,
"SecurityType"=> 1,
"ShowCoverImage"=> false,
"SmugSearchable"=> 1,
"SortDirection"=> 2,
"SortMethod"=> 5,
"Type"=> 4,
"UrlName"=> $urlName,
"WorldSearchable"=> 1
);

$option = json_encode($option);
$client->post('node/xxxxx!children', $option); //xxxxx => nodeId

Upload results in duplicate filename

With phpSmug version 3.5, image uploads result in the FileName being duplicated. For example, if I upload "foo.jpg", the FileName as stored on the SmugMug site ends up being "foo.jpg, foo.jpg".

I believe this is because the X-Smug-Filename header is being duplicated. In particular, this bit of code:

   /* Optional Headers */
    foreach( $args as $arg => $value ) {
        if ( $arg == 'File' ) continue;
        $upload_req->setHeader( 'X-Smug-' . $arg, $value );
    }

will cause X-Smug-FileName to be set a second time.

I changed the code like this:

   /* Optional Headers */
    foreach( $args as $arg => $value ) {
        if ( $arg == 'File' ) continue;
        if ( $arg == 'FileName' ) continue;
        $upload_req->setHeader( 'X-Smug-' . $arg, $value );
    }

and the duplicate names went away. This of course is not the most elegant way to handle the problem but it does illustrate that the duplicate headers is probably the problem.

I want to add Authorization Header while accesing the images

Hi,

I am getting blank images when I try to access the images using $images = $f->images_get("AlbumID={$albums['0']['id']}", "AlbumKey={$albums['0']['Key']}", "Heavy=1"); and I am able to see the image url but it just displays the blank image and the same image url which is accessed through code can be accessible through browser.

When I approached the smugmug team they suggested to add the Authorization Header while accessing the images some thing like this

This is excerpt from Oauth 1.0 soecs regarding authorization header. You should include this header, with your values naturally, to the request for images.

5.4.1. Authorization Header

The OAuth Protocol Parameters are sent in the Authorization header the following way:

Parameter names and values are encoded per Parameter Encoding.
For each parameter, the name is immediately followed by an ‘=’ character (ASCII code 61), a ‘”’ character (ASCII code 34), the parameter value (MAY be empty), and another ‘”’ character (ASCII code 34).
Parameters are separated by a comma character (ASCII code 44) and OPTIONAL linear whitespace per [RFC2617].
The OPTIONAL realm parameter is added and interpreted per [RFC2617], section 1.2.

For example:

            Authorization: OAuth realm="http://sp.example.com/",
            oauth_consumer_key="0685bd9184jfhq22",
            oauth_token="ad180jjd733klru7",
            oauth_signature_method="HMAC-SHA1",
            oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D",
            oauth_timestamp="137131200",
            oauth_nonce="4572616e48616d6d65724c61686176",
            oauth_version="1.0"

I tried to add this my code as below and my idea is to access the images with header but it is not working. How best we can add the header

$albums = $f->albums_get('Heavy=false');
$sig = $f->generate_signature( 'Get', array( 'FileName' => $albums['0']['Key'] ) );
$f->setHeader( 'Authorization', 'OAuth realm="http://api.smugmug.com/",
oauth_consumer_key="'.$f->APIKey.'",
oauth_token="'.$f->oauth_token.'",
oauth_signature_method="'.$f->oauth_signature_method.'",
oauth_signature="'.urlencode( $sig ).'",
oauth_timestamp="'.$f->oauth_timestamp.'",
oauth_version="1.0",
oauth_nonce="'.$f->oauth_nonce.'"' );
// Get list of public images and other useful information
$images = $f->images_get("AlbumID={$albums['0']['id']}", "AlbumKey={$albums['0']['Key']}", "Heavy=1");

How to pull from specific folder / gallery

I'm attempting to pull and show images from a specific gallery and folder of galleries. Looking at the example code in the download, how would I modify the example code to pull this? I think this goes in tandem with the question, but how do I discover the AlbumID and AlbumKey for my galleries?

$images = $f->images_get( "AlbumID={$albums['0']['id']}", "AlbumKey={$albums['0']['Key']}", "Heavy=1" );

Fatal Error : Class Not found phpsmug\Client

Hello there,
I intalled compose using SSH2 and it has got installed in ~/.composer directory. I have uploaded to the zip files to ~/smugmug/php and library folder at ~/smugmug/php/lib/phpSmug where Client.php resides.
Also note that the vendor directory is installed in ~/.composer/vendor with autoloader.php

I ran into 2 issues

  1. When running composer update , it throws "Problem 1

    • The requested package lildude/phpsmug No version set (parsed as 1.0.0) is satisfiable by lildude/phpsmug[No version set (parsed as 1.0.0)] but these conflict with your requirements or minimum-stability". Well, my composer.json is already having this
      "require": {
      "lildude/phpsmug": "^4.0",
      "php": ">=5.5.0",
      "guzzlehttp/guzzle": "~6.1",
      "guzzlehttp/oauth-subscriber": "0.3.*"
      },
  2. Ignoring this, I am unable to load phpSmug\Client class and shows this error Fatal error: Class 'phpSmug\Client' not found in /home2/visionone/public_html/smugmug/php/example.php on line 49

Error ocurred during the Image upload from our server to SmugMug

Hi,

Below is the error occurring frequently while i am trying to upload the images from our sever to smugmug using phpSmug API - 3.4

Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to api.smugmug.com' in phpSmug/phpSmug.php:1464 
Stack trace: 
#0 /home/public_html/phpSmug/phpSmug.php(1201): PhpSmugSocketRequestProcessor->execute('POST', 'http://api.smug...', Array, 'AlbumID=1856125...', Array) 
#1 /home/public_html/phpSmug/phpSmug.php(408): httpRequest->execute() 
#2 /home/public_html/phpSmug/phpSmug.php(748): phpSmug->request('images.uploadFr...', Array) 
#3 [internal function]: phpSmug->__call('images_uploadFr...', Array) 
#4 /home/public_html/Test-smugmug-api-upload.php(85): phpSmug->images_uploadFromURL('AlbumID=1856125...', 'URL=http://img1...', 'FileName=39251-...', 'Caption=39251-B...', 'Heavy=1') 
#5 {main} thrown in /home/public_html/phpSmug/phpSmug.php on line 1464

I am trying to upload 100 images each of size 3 MB, When a page is loading, the authentication occurs with the API and upload 10 images at a time. then there is meta refresh tag added at the bottom of the page to reload for processing the next 10 images. This is the way i implemented to upload the images 10/100 per cycle

Please advise me what did i wrong here?

Keywords not showing up?

I've contacted smugmug about this, but I think it could be related to using phpSmug so I figured I'd ask about it here.

This request:
https://www.smugmug.com/api/v2/image!search?_shorturis=1&_verbosity=3&APIKey=gGQr6mjMgCCrSWv5q3HxMzzKbF8NjkSM&_expand=ImageSizes&_expandmethod=inline&Scope=album%2FfhvMbR&Keywords=&count=100&_accept=application%2Fjson

when performed directly from the browser returns correctly, However; when the same request is sent through phpSmug the results all have empty Keyword and KeywordArray properties.

I've debugged the phpSmug Client as best I can and it appears the raw results from the Guzzle Client are even returning results missing Keywords...

Anyone have any idea what's going on?

Debugging 400 response

Hi,

We're upgrading to the 4.0 release, and having trouble debugging a call to create an album. We get a 400 response and the 'readable' error is such:

Client error: `POST https://api.smugmug.com/api/v2/folder/user/[username]!albums` resulted in a `400 Bad Request` response:
{"Options":{"Methods":["POST"],"ParameterDescription":{"Varchar":"Variable length text from MIN_CHARS to MAX_CHARS (MAX_ (truncated...)

I suspect something is wrong with my request, but not sure what exactly.

Does SmugMug's API provide a "Here's exactly what's wrong with your request" message that we can access, or do they just return a list of the parameters they expect at that endpoint (which is what it seems to be doing above, albeit truncated by phpSmug)?

Feature request: support for _config

The SmugMug API supports an advanced syntax for expansions using a _config parameter, documented at https://api.smugmug.com/api/v2/doc/advanced/config.html

Currently, I can make use of this in phpSmug by creating the appropriate array and then encoding it myself:

$advanced = [
    'filter' => [ 'Name', 'Description' ],
    'filteruri' => [ 'HighlightImage' ],
    'expand' => [
        'HighlightImage' => [
            'filter' => [ 'ThumbnailUrl' ],
            'filteruri' => []
        ]
    ]
];

$request_options = [
    '_expandmethod' => 'inline',
    '_config' => json_encode($advanced)
];

$client->get('user/me!albums', $request_options);

It would be nice if phpSmug recognized the _config key in an $options array and performed the JSON encoding automatically.

Fatal Error when using phpSmug v3.4 as of 4/22/2016

We have an application that is using phpSmug v 3.4 and version 1.2.2 of the SmugMug API. As of April 22nd we are getting the following error when attampting to run the application and log into SmugMug.

"Fatal error: Cannot redeclare class HttpRequestException in /home4/sniperac/public_html/locations/TAG/includes/phpSmug/phpSmug.php on line 904"

Any ideas? Is it time to upgrade the application to use phpSmug 4 and 2.0 version of the API?

Thanks,
Ryan

400 Error code creating album, please help.

Has anyone had 400 Bad Request errors when creating albums?

This is my code

try {
    // Create
    $album = $client->post( $endpoint, $options );
    return $album;
 } catch ( BadResponseException $ex ) {
    var_dump( $ex->getResponse()->getBody()->getContents() ); 
}

This is my request data:

  'UrlName' => string 'wp-smugmu-local-test-32' (length=23)
  'Name' => string 'Test' (length=4)
  'Privacy' => string 'Public' (length=6)
  'Description' => string 'Album published from a WP Gallery in smugmug website.' (length=54)

This is my endpoint /api/v2/folder/user/myuser/January-2019!albums

And I'm getting this error:

{"Response":{"Uri":"/api/v2/folder/user/myuser/January-2019!albums?_verbosity=1","Locator":"Album","LocatorType":"Objects"},"Code":400,"Message":"Bad Request"}

Any ideas?

Thanks in advance!

404 returned just for our Smugmug site album list

I don't know whether this is something anyone has seen before or can provide any advice about, but I am at my wits' end because it seems to make no sense at all.

Our app, which was working fine for most of the year up to last week, now refuses to play due to a 404 error when trying to access /user/ouraccount!albums

Bizarrely:
- if I change ouraccount in the above to a different Smugmug account, it works;
- if I change !albums to another endpoint like !featuredalbums, I get no 404; and
- if I copy the 404'd URL from the app's logs/terminal and paste it into a browser, it sometimes works

I've stripped it down to the code to its bare minimum and here's the offending bit:

$client=smugmug_instantiate();
$repositories = $client->get('user/********!albums');
foreach ($repositories->Album as $alb)
    {
    print "Album: ".$alb->Name."\n";
    }

Literally, if I change our account handle in the above to the name of another account, I get a list of their albums. If I put it back to ours, I get a 404. I even tried changing the name of our Smugmug account temporarily, but got the same behaviour as above with the new name.

The whole of the script I'm testing with is only 16 lines long including the above bit and the instantiate function. If I move it to a different computer on a different network with a fresh phpSmug installation, I still get the same behaviour.

The actual error when run in the terminal looks like this:

$ php tryme.php 
PHP Fatal error:  Uncaught GuzzleHttp\Exception\ClientException: Client error: `GET https://api.smugmug.com/api/v2/user/*******!albums` resulted in a `404 Not Found` response:
{"Response":{"Uri":"/api/v2/user/********!albums","Locator":"Album","LocatorType":"Objects","UriDescription":"All of use (truncated...)
 in /tmp/smuglocal/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /tmp/smuglocal/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /tmp/smuglocal/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /tmp/smuglocal/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /tmp/smuglocal/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /tmp/smuglocal/vendor/guzzl in /tmp/smuglocal/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

Is this at all familiar?

Many thanks,

Adrian

Can't upload (from URI & from Local)

Hello,

First I would like to thank you for your work, which is really helpful to use Smugmug :) !

I have successfully used those functions from the API: loggin/oauth, fetch any kind of element, post a folder, edit a folder, delete a folder, ...

Basically everything is working well, but I'm now trying to upload something, but nothing is working until now (I have a symfony4 environement, last PHP, last version of your library).

For the Local upload (as it is mentionned option is optionnal, I removed everything inside):

$options = []
$response = $client->upload('album/7Wwsdk', "/Users/antoinenedelec/Documents/Photos/IMG_0375.JPG", $options);

I then have this response:

object(stdClass)[1065]
public 'stat' => string 'fail' (length=4)
public 'method' => string 'smugmug.images.upload' (length=21)
public 'code' => int 5
public 'message' => string 'system error' (length=12)

I did tried to chmod 777 my file, nothing will do.

For the external upload:

        $image_allow_insecure = true;
        $image_uri = 'http://lasoundbox.fr/img/app_bg.png';
        $image_cookie = '';
        $image_title = 'test';
        $image_caption = 'Caption';
        $image_hidden= false;
        $image_file_name = 'test.jpg';
        $image_keyword = '';

        $options = [
            'AllowInsecure' => $image_allow_insecure,
            'Uri' => $image_uri,
            'Cookie' => $image_cookie,
            'Title' => $image_title,
            'Caption' => $image_caption,
            'Hidden' => $image_hidden,
            'FileName' => $image_file_name,
            'Keywords' => $image_keyword,
        ];

        $response = $client->post('album/7Wwsdk!uploadfromuri', $options);

And i get this response:

{"Response":{"Uri":"/api/v2/album/7Wwsdk!uploadfromuri","UriDescription":"Upload a photo or video from elsewhere on the web","EndpointType":"UploadFromUri"},"Code":404,"Message":"Not Found"}

I did checked that my "7Wwsdk" element exists, and is indeed a folder.

I think i'm probably doing something wrong here, as everything else is working but couldn't fint what yet ? Maybe because i'm in local for the development (using Symfony built in local server) ?

Any idea ?

Sorting Albums by Date Added Decending

From the Smug Mug API im trying to get() with sorting Decending... and getting an error with your wrapper.

This is from Smug Mug
user/{$username}!albums?MinimumImages=0&Order=Date+Added+%28Descending%29

Using with your wrapper:
$albums = $client->get("user/{$username}!albums", array('count' => 2, 'MinimumImages'=> 0, 'Order'=>'Date+Added+%28Descending%29', '_shorturis' => true));

Provides this error:

Client error: GET https://api.smugmug.com/api/v2/user/myusername!albums?count=2&MinimumImages=0&Order=Date%2BAdded%2B%2528Descending%2529&_shorturis=1 resulted in a 400 Bad Request

is it encoding improperly?

$callback url doesn't work!

Hi there,
I have a problem with using this lib.

    require_once 'vendor/autoload.php';
    $options = [
        'AppName' => SMUGMUG_APPNAME . '/1.0 (' . HTTPS_ROOT . ')',
        '_verbosity' => 1, 
        'OAuthSecret' => SMUGMUG_OAUTH_SECRET, 
    ];
$client = new phpSmug\Client(SMUGMUG_APIKEY, $options);
$callback = 'https://aaa.com/smugmugs/callback';
$request_token = $client->getRequestToken($callback);
$html                        = "<p>Click <a href='" . $client->getAuthorizeURL() . "' target='_blank'><strong>HERE</strong></a> to Authorize.</p>";
echo $html;

when I click to get access from smugmug and it just redirect to the root path of my site:
https://aaa.com/?oauth_token=XXX&...
Why can't it redirect to the callback url i specified above?
Anything I did wrong on my code above?

Thanks.

Saving/Reusing the Token

Hello,

I am looking at the oAuth example and trying to use this so I don't have to constantly login every time I go to a new page:

$options = [ 'AppName' => 'My Cool App/1.0 (http://app.com)', ]; $client = new phpSmug\Client($APIKey, $options); $client->setToken($_SESSION['token'], $_SESSION['tokensecret']);
but I get this error message:

An OAuthSecret is required for all SmugMug OAuth interactions. (Error Code: 0)

The session variables and other variable I am using are populated.

I am sure I am missing some basic concept...I just don't know what I don't know and I have searched all over to figure it out without having to bother someone about it. Would you please let me know what I am doing wrong?

Thanks,
Matt

Problems with phpSmug 3.5 and API 1.3

I have long used phpSmug with API 1.2 to serve some images on my website, but SmugMug recently turned that version off. So I'm updating to 1.3 and am having some problems. (I don't have composer available in my environment, so I can't move to phpSmug 4 and API 2.)

I've done the OAuth dance to get an access token, but now I'm getting a 400 Bad Request when I make a call. Here's sample code:

$sm = new phpSmug("APIKey=$key", "APIVer=1.3.0", "AppName=foobar", "OAuthSecret=$secret");
$sm->setToken("id=$accessToken_id", "Secret=$accessToken_secret");
$albums = $sm->albums_get();

Am I missing something obvious here?

Issue updating keywords

I'm trying to update keywords in existing photos. I have uploads working, can traverse directories, and can get gallery images.

Using the API tool works fine and updates the photos.
https://api.smugmug.com/api/v2/image!addkeywords

But when making this request, I get the same 400 error every time. Any thoughts or working examples?

$options['Async'] = false;
$options['ImageUris'] = [$image]; // the string uri
$options['keywords'] = implode(',',$keywords);

try {
$response = $this->client->post("/api/v2/image!addkeywords",$options);
} catch (\GuzzleHttp\Exception\ClientException $e) {
// always 400
}

nonce_used error when getting image information

Hello,

I am using the library to connect my club's Drupal website to Smugmug. I have it working for uploading images and for getting the image count of a gallery. I seem to be stuck on viewing an image, though.

When I try to access an image via its key, I get:

Client error: GET https://api.smugmug.com/api/v2/image/WprRLwK?_verbosity=1 resulted in a 401 Unauthorized response:
{"Code":401,"Message":"oauth_problem=nonce_used"}

It's a public image so you can put that URL into a browser and see that it exists and retrieves the information just fine without oauth. I don't know a lot about oauth. From what little I could get out of Google, it sounds like some token is being sent more than once? But the tokens always stay the same so what I'm finding isn't making any sense to me.

$this->client->get("/api/v2/album/$key"); works but $this->client->get("/api/v2/image/$key"); gets me the nonce_used error.

I'd appreciate any help. I tried posting in the Smugmug forum but haven't gotten any response. Hoping you can help me as I'm totally stuck at this point.

Thanks,

Michelle

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.