Need help with smugmug.images.changeSettings
elyobelyob
Registered Users Posts: 53 Big grins
Hi,
I'm just playing about with the API again. I think I've got a fair amount of it sussed. I am just trying to get the changeSettings to work so I can move photos from one album to another. I've got as far as getting an OK from the debug, but no movement. I'm not sure I've got the struct sedning correct, and how to view the output boolean. Thanks for any help.
The PHP code is ..
function changeAlbumSettings($session_id, $images_id) {
$get_images_struct = new xmlrpcval(array(
SessionID => new xmlrpcval($session_id, "String"),
ImageID => new xmlrpcval(32827392, "int"),
array (AlbumID => new xmlrpcval(745010, "int"),
Caption => new xmlrpcval("MyCaption", "string"),
Keywords => new xmlrpcval("MyKeywords", "string"), "struct")));
$xmlrpc_client = new xmlrpc_client("/hack/xmlrpc/", "api.smugmug.com", "443");
$xmlrpc_client->setDebug(1);
$get_images_msg = new xmlrpcmsg('smugmug.images.changeSettings', $get_images_struct);
$get_images_response = $xmlrpc_client->send($get_images_msg, '0', 'https');
if (!$get_images_response) { die("getimages failed"); }
$get_images_value = $get_images_response->value();
if (!$get_images_response->faultCode()) {
$images_array = php_xmlrpc_decode($get_images_value);
return $images = $images_array;
} else {
print "Fault: Code: " . $get_images_response->faultCode() . " Reason: " .$get_images_response->faultString()."<br />";
return 0;
}
}
The Debug output is ..
---GOT---
HTTP/1.1 200 OK
Date: Sat, 20 Aug 2005 22:22:46 GMT
Server: Apache
X-Powered-By: smugmug/1.2.0
Cache-Control: private, max-age=1, must-revalidate
Pragma:
Set-Cookie: SMSESS=; path=/; domain=.smugmug.com
ETag: sm-2beab780519903ae9dbbddf8df287383-sm
Content-Length: 151
Content-Type: text/xml
<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
<param>
<value>
<string/>
</value>
</param>
</params>
</methodResponse>
---END---
</pre>
HEADER: Date: Sat, 20 Aug 2005 22:22:46 GMT
HEADER: Server: Apache
HEADER: X-Powered-By: smugmug/1.2.0
HEADER: Cache-Control: private, max-age=1, must-revalidate
HEADER: Pragma:
HEADER: Set-Cookie: SMSESS=; path=/; domain=.smugmug.com
HEADER: ETag: sm-2beab780519903ae9dbbddf8df287383-sm
HEADER: Content-Length: 151
HEADER: Content-Type: text/xml
</pre>
---EVALING---[17 chars]---
new xmlrpcval("");
---END---</pre>
I'm just playing about with the API again. I think I've got a fair amount of it sussed. I am just trying to get the changeSettings to work so I can move photos from one album to another. I've got as far as getting an OK from the debug, but no movement. I'm not sure I've got the struct sedning correct, and how to view the output boolean. Thanks for any help.
The PHP code is ..
function changeAlbumSettings($session_id, $images_id) {
$get_images_struct = new xmlrpcval(array(
SessionID => new xmlrpcval($session_id, "String"),
ImageID => new xmlrpcval(32827392, "int"),
array (AlbumID => new xmlrpcval(745010, "int"),
Caption => new xmlrpcval("MyCaption", "string"),
Keywords => new xmlrpcval("MyKeywords", "string"), "struct")));
$xmlrpc_client = new xmlrpc_client("/hack/xmlrpc/", "api.smugmug.com", "443");
$xmlrpc_client->setDebug(1);
$get_images_msg = new xmlrpcmsg('smugmug.images.changeSettings', $get_images_struct);
$get_images_response = $xmlrpc_client->send($get_images_msg, '0', 'https');
if (!$get_images_response) { die("getimages failed"); }
$get_images_value = $get_images_response->value();
if (!$get_images_response->faultCode()) {
$images_array = php_xmlrpc_decode($get_images_value);
return $images = $images_array;
} else {
print "Fault: Code: " . $get_images_response->faultCode() . " Reason: " .$get_images_response->faultString()."<br />";
return 0;
}
}
The Debug output is ..
---GOT---
HTTP/1.1 200 OK
Date: Sat, 20 Aug 2005 22:22:46 GMT
Server: Apache
X-Powered-By: smugmug/1.2.0
Cache-Control: private, max-age=1, must-revalidate
Pragma:
Set-Cookie: SMSESS=; path=/; domain=.smugmug.com
ETag: sm-2beab780519903ae9dbbddf8df287383-sm
Content-Length: 151
Content-Type: text/xml
<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
<param>
<value>
<string/>
</value>
</param>
</params>
</methodResponse>
---END---
</pre>
HEADER: Date: Sat, 20 Aug 2005 22:22:46 GMT
HEADER: Server: Apache
HEADER: X-Powered-By: smugmug/1.2.0
HEADER: Cache-Control: private, max-age=1, must-revalidate
HEADER: Pragma:
HEADER: Set-Cookie: SMSESS=; path=/; domain=.smugmug.com
HEADER: ETag: sm-2beab780519903ae9dbbddf8df287383-sm
HEADER: Content-Length: 151
HEADER: Content-Type: text/xml
</pre>
---EVALING---[17 chars]---
new xmlrpcval("");
---END---</pre>
0
Comments
Just print_r'd the output from the script ...
xmlrpcval Object ( [me] => Array ( [string] => ) [mytype] => 1 )
Any help?
$get_images_struct = new xmlrpcval(Array(SessionID => new xmlrpcval($session_id), ImageID => new xmlrpcval(32827392, "int"), Array (AlbumID => new xmlrpcval(745010, "int"), Caption => new xmlrpcval("MyCaption"), Keywords => new xmlrpcval("MyKeywords"), "struct")));
Thanks (this group is my final hope to get this working).
My PHP is a bit rusty, are yuo able to output the contents of $get_images_struct after you create it ? perhaps print $get_images_struct ? That way I will be able to determine if what is being generated is correct.
Cheers,
David
SmugMug API Developer
My Photos
---GOT---
HTTP/1.1 200 OK
Date: Tue, 23 Aug 2005 14:52:09 GMT
Server: Apache
X-Powered-By: smugmug/1.2.0
Cache-Control: private, max-age=1, must-revalidate
Pragma:
Set-Cookie: SMSESS=; path=/; domain=.smugmug.com
ETag: sm-2beab780519903ae9dbbddf8df287383-sm
Content-Length: 151
Content-Type: text/xml
<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
<param>
<value>
<string/>
</value>
</param>
</params>
</methodResponse>
---END---
</pre>
HEADER: Date: Tue, 23 Aug 2005 14:52:09 GMT
HEADER: Server: Apache
HEADER: X-Powered-By: smugmug/1.2.0
HEADER: Cache-Control: private, max-age=1, must-revalidate
HEADER: Pragma:
HEADER: Set-Cookie: SMSESS=; path=/; domain=.smugmug.com
HEADER: ETag: sm-2beab780519903ae9dbbddf8df287383-sm
HEADER: Content-Length: 151
HEADER: Content-Type: text/xml
</pre>
---EVALING---[17 chars]---
new xmlrpcval("");
---END---</pre>