• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.
  • Chevereto Support CLST

    Support response

    Support checklist

    • ⚠️ Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • ✅ Confirm that the server meets the System Requirements
    • 🔥 Check for any available Hotfix - your issue could be already reported/fixed
    • 📚 Read documentation - It will be required to Debug and understand Errors for a faster support response

API to post to user account and album

marcanthonyphoto

Chevereto Member
I read the documentation on the API and got uploading to work to a users account except that you are hardcoding the name (i.e.CHV\Image::uploadToWebsite($source, 'jesse')😉 . I want to change the uploadtowebsite to be like this CHV\Image::uploadToWebsite($source, $user_id, $album); This way the api would upload into a users account and album based on the get statement like this.
https://www.yoursite.com/api/1/uplo...uruseraccount&album=youralbumname&format=json

Can this be done? If so, how. I need this bad.
 
No, the API doesn't have such feature. You will need to add that functionality on your own.
 
Are you going to add that in v4? If you're going to have an API for uploading it only makes sense to allow for uploading into a users album
 
V3 API is just a route that listens to certain requests, every method needs to be manually added so when I add a class method that function must be manually added to the API.

V4 API will be different because it will bind every method automatically meaning that every single action or procedure will be immediately available as an API endpoint.

Day and night, V4 will be build from scratch to have this 1:1 API.
 
Thanks. I did find a way to do it for the user id but I can't find a way to post into an album of that user. Here's what I added to route.api.php. Any thoughts on what I can add to post into the album name?

Right under
$route = function($handler) {
try {

I added this

$user = $_REQUEST['user'];
if (is_null($user)) {
$user = 'nouser';
}


Then I added this

$uploaded_id = CHV\Image::uploadToWebsite($source, $user);


Now when I enter something like this it posts the photo into the users account from the get statement. But any thoughts on what I can add to this code to now post into an album name in the user account?

mysite.com/api/1/upload/?key=32f229aed28b&source=http://www.test.com/image23.jpg&user=marcanthony&format=json
 
Easy, start by digging.

Open app/lib/classes/class.image.php and search for uploadToWebsite

And open app/routes/route.json.php and look for $uploaded_id
 
Thanks for the assistance. I tried but didn't have any luck. No matter what I change it still posts into the users main account but won't post into the users album. I know you are very busy but if you can just take a minute to modify my codes to allow for it to work it would mean so much to me. I'm stuck and this is really important. If not, I understand. If you can, it would be greatly appreciated. I am looking for posting to be like this.

mysite.com/api/1/upload/?key=32f229aed28b&source=http://www.test.com/image23.jpg&user=marcanthony&album_name=thename&format=json

Here are my files www.ipixsocial.com/files.zip
 
Pay attention to the actual code. Album parameter must be passed as ID.
 
OK. I will look into that. The problem is when a user creates an album how will they know what the ID is? Also, I am having an issue with my iPhone app that I am developing. I am posting to the api using base64 as source. The problem is it is getting rejected by the server because the string is too long. Any thoughts on this? I know you're not an iPhone developer but maybe you see something that would help send a photo from my iPhone as a local file to the api.


NSData *imageData = UIImageJPEGRepresentation(_capturedImage, 0.5);



NSString *imageB64 = [imageData base64EncodingWithLineLength:0];

imageB64 = [imageB64 encodedURLString];

NSURL * url = [NSURL URLWithString:[NSString stringWithFormat: @"https://www.site.com/gallery/api/1/...&source=imageB64&user=marcanthony&format=json"]];



NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

[request setURL:url];

[request setHTTPMethod😡"POST"];
 
Thanks. I did find a way to do it for the user id but I can't find a way to post into an album of that user. Here's what I added to route.api.php. Any thoughts on what I can add to post into the album name?

Right under
$route = function($handler) {
try {

I added this

$user = $_REQUEST['user'];
if (is_null($user)) {
$user = 'nouser';
}


Then I added this

$uploaded_id = CHV\Image::uploadToWebsite($source, $user);


Now when I enter something like this it posts the photo into the users account from the get statement. But any thoughts on what I can add to this code to now post into an album name in the user account?

mysite.com/api/1/upload/?key=32f229aed28b&source=http://www.test.com/image23.jpg&user=marcanthony&format=json

Thanks, working perfectly. This guide is more straight forward than the APIv1 document(https://chevereto.com/docs/api-v1) for enabling user account upload. The API document says "API V1 one doesn't have a way to upload images associated with a given user" which is no longer the case. The workaround given was also complex and only for a single account.
 
By the way, use album_public_id rather than album names to insert those files, the query is less expensive.
 
From the image URL you can know the public id (encoded) which you must decode with decodeID(). With the integer ID (decoded) you can query the image table to retrieve the image album id. With the album id you can query the album table and retrieve the values you are looking for.
 
Back
Top