lildude / phpsmug Goto Github PK
View Code? Open in Web Editor NEW: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
: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
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/
Uploads have started to fail because phpSmug uploads to api.smugmug.com and not upload.smugmug.com.
Reported by Brian Steele on 23 Sep '09
— Ticket #5 Migrated from http://phpSmug.com
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.
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
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.
A warning about potential performance impact of this choice would need to be documented too
Reported by Me on 18 May '11
— Ticket #9 Migrated from http://phpSmug.com
With the switch to using Guzzle, getting this working should now be possible.
At the moment the cache is cleared/expired before a connection is made. phpSmug should rather keep the cache and only over-write it if the API endpoint is responsive.
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.
Greetings,
I'm jumping into the space and was wondering if there is an example using phpSmug and pulling from a specific album?
I notice you've not merged a fairly important branch change into master, are you no longer maintaining this?
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.
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:
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
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.
Reported by Aaron on 28 Aug '09
— Ticket #4 Migrated from http://phpSmug.com
phpSmug should use the documented secure.smugmug.php API endpoints for secure communication
Reported by Me on 18 May '11
— Ticket #8 Migrated from http://phpSmug.com
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.
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!
This status is only going to change when the 2 PEAR modules phpSmug rely on become E_STRICT compliant, or I can find a good alternative without re-writing the code myself.
Reported by Me on 9 Nov '08
— Ticket #2 Migrated from http://phpSmug.com
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:
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?
Calls to methods which "unset" values by passing an empty string fail with "invalid signature" when using OAuth.
Reported by Anthony Humes on 1 Jun '11
— Ticket #11 Migrated from http://phpSmug.com
I'm having a couple of problems with expansions in v4.
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
?
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.
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
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.
Issue is posted on StackOverflow:
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");
phpSmug forces the use of the 1.2.2 API for OAuth even when providing APIVer=1.3.0 on instantiation.
Reported by Marty Thornley on 18 May '11
— Ticket #10 Migrated from http://phpSmug.com
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" );
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
When running composer update , it throws "Problem 1
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
Until this is resolved, ensure you use a dedicated directory for caching.
Reported by Me on 20 Nov '08
— Ticket #3 Migrated from http://phpSmug.com
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?
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.
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?
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)?
login_*() method calls are incorrectly handled when used instead of the phpSmug specific single unified login() method.
Reported by Chris Abbey on 3 Jan '10
— Ticket #6 Migrated from http://phpSmug.com
API 2.0 is currently open to beta testers so lets get phpSmug using it.
Photos uploaded with "hidden" option aren't hidden when they arrive at SmugMug
Reported by Jerry Roek on 20 Jun '11
— Ticket #12 Migrated from http://phpSmug.com
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.
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
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!
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
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 ?
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?
If you arrive at a page with the link to go to SmugMug and refresh it without doing anything, it fails with the error of invalid tokens. Even happens on your test page at http://phpsmug.com/examples if you hit refresh straight away.
Error code not being passed to Exception() on line 350 of phpSmug.php (rev 2.0)
Reported by MVA on 7 Nov '08
— Ticket #1 Migrated from http://phpSmug.com
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.
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
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?
Changes introduced in phpSmug 2.2 break the automatic OAuth token handling and passing.
Reported by Mark Steudel on 4 Oct '10
— Ticket #7 Migrated from http://phpSmug.com
According to this post http://www.dgrin.com/showthread.php?t=83918 when SmugMug is in read-only mode it is still possible to retrieve data from the API if done anonymously.
But it appears that phpSmug does not support this as I am currently receiving this error and unable to retrieve data.
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
}
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.