Closed joeporterme closed 6 years ago
its doesnt like the encoded "+" symbol you are doing...
This is where phpSmug is making your life easy and assumes you have no knowledge about encoding the params as there is no documentation that manual encoding is required within the SmugMug API docs.
The API itself suggests manual encoding of options is not required so phpSmug passes this on to you and expects you to use the options exactly as they're returned by the API.
So in the case of ordering, the API supports the following (taken from the JSON from https://api.smugmug.com/api/v2/user/{username}!albums#json
):
"Parameters": {
"GET": [
{
"Name": "Order",
"Required": false,
"ReadOnly": false,
"Default": "",
"Description": "Order Albums By",
"Type": "Select",
"OPTIONS": [
"Album Settings",
"Position",
"Last Updated (Descending)",
"Last Updated (Ascending)",
"Date Added (Descending)",
"Date Added (Ascending)"
],
"MIN_COUNT": 1,
"MAX_COUNT": 1
},
{
"Name": "MinimumImages",
"Required": false,
"ReadOnly": false,
"Default": 0,
"Type": "Integer",
"MIN_VALUE": 0,
"MAX_VALUE": 16777215
}
]
},
From this output, you can see the ordering string is Date Added (Descending)
.
Use that exactly (I've removed default options)...
$albums = $client->get("user/{$username}!albums", array('count' => 2, 'Order'=>'Date Added (Descending)'));
... and you'll get the response you expect.
AHH sorry... that did work...
Now if we can just get SMUG to speed up their API... sheesh... a simple get 2 albums info takes 10 seconds to load. And i just want to display some pictures on a website.
Im probably going to have to just sync all the data to a database and have the front end query that database instead of SMUG API
AHH sorry... that did work...
:tada: Good to hear it.
Now if we can just get SMUG to speed up their API... sheesh... a simple get 2 albums info takes 10 seconds to load. And i just want to display some pictures on a website.
I hear you 😞. When I first switched to using Guzzle for the HTTP requests I did a little experimenting with caching with a few different Guzzle-compatible caching modules but found I needed to get hacky or overly loose with the caching as SmugMug's headers don't encourage clean caching. Using a local DB or storing the response in a local JSON file is probably the least hacky and most performant of all options at the moment.
I'm gonna close this issue now as the initial issue is now resolved.
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 a400 Bad Request
is it encoding improperly?