urgent - Developing a program using API

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Hi there,

I am trying to develop a software for file upload using the API provided in this script and i am having troubles with file upload API.

I dont know how to specify the file path in the "upload_file=" parameter. I have tried full path, relative path, etc but no luck.

When i use the testing tool, it gives me:
upload_file=C%3A%5Cfakepath%5Cfilename.txt and i understand it is trying to say C:\fakepath\filename.txt but I am not sure what this fakepath is ?

Any ideas anybody ? Thanks in advance.
 

adam

Administrator
Staff member
Dec 5, 2009
2,043
108
63
Hi,

You need to post it like in this example:

https://stackoverflow.com/questions/15200632/how-to-upload-file-using-curl-with-php

Obviously replace the params with what the API requires.

The testing tool in the admin area may also help understand it:

https://fhscript.com/admin/api_test_framework.php

Thanks,
Adam.
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Thanks for pointing me Adam,
The API testing tool doesnt really give me what type of information file upload parameter accepts, what datatype and how so i was confused.
Anyways, i will give this a try and let you know if it doesnt work for me.
Thanks
 

relinkto4664

New Member
YetiShare User
YetiShare Supporter
Reservo User
Reservo Supporter
Jan 1, 1970
37
4
0
Adam thanks for coding such "USELESS" API!!!
Really you make me always angry because you don't code functions that fit the costumers need!

First of all. The file-info API must be accessible for third services and not only for members and not only for their own files!
There are many examples why an API like that must be public. One and the simplest example is a download tool.

And API Input FILE-ID? This must be a fault, nobody search for a FILE-ID!

URL would be the right Input! http://domain.com/2e4886ae0227423e
 
  • Like
Reactions: dgogoasa

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Well i kind of like the API, a little bit more explanation in some areas would have been better.
@brainbreaker - Not sure how you plan on using this API but if you are developing a program, you always want to go by a unique identifier which in our case is file_id.
Other way could have been by using the short URL (eg: 2e4886ae0227423e from your example URL: http://domain.com/2e4886ae0227423e) but this can be easily done. you just need 1 more piece of API code to get file_ID from the database using short URL..... You can just copy the existing API code and change the code to get whatever you need..

Hope this helps.
 

relinkto4664

New Member
YetiShare User
YetiShare Supporter
Reservo User
Reservo Supporter
Jan 1, 1970
37
4
0
I think a member can't find the "file_id" via user panel, so this is not the right identifier. why not use the "short url"? it so easy and simple.
And yes i can modify this easy at my own service but i also develope for a download tool and there we need a public api which works.
Otherwise we must always develop specially plugin for each yetishare webpage which has a modified template.

Sorry but this stupid and time-consuming.
 
  • Like
Reactions: dgogoasa

adam

Administrator
Staff member
Dec 5, 2009
2,043
108
63
brainbreaker said:
I think a member can't find the "file_id" via user panel, so this is not the right identifier. why not use the "short url"? it so easy and simple.
And yes i can modify this easy at my own service but i also develope for a download tool and there we need a public api which works.
Otherwise we must always develop specially plugin for each yetishare webpage which has a modified template.

Sorry but this stupid and time-consuming.
I think you're using the API differently to what it's intended for, you're using it as a download manager/leech rather than integration into a file manager app, for example.

I would imagine most apps would first be interested in a list of files available within the account, this can be done via the API. Then a user would request download of a file, you have the file_id by this stage so you can easily download the file via the API.

What you're referring to is an option to download a file directly using the short url, but I don't understand why you wouldn't have the file_id from the list of files you've requested previously. Eitherway, it wouldn't be too hard to add, have a look at the API code and just add a lookup on the file based on short_url rather than id.
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
I had no luck with the file upload API... Not sure how i can pass the file path and name using curl. I have seen the example page and tried all options but no luck..

This is the URL i get when using API testing but for upload_file, i get C:/fakepath/document.pdf and i dont know how to pass this path.

https://www.website.com/api/v2/file/upload
?access_token=qZUBFgiXTLojbQT09f0sBnAgbaDSYgzJEHSq85m9af*****************************5wikiE9qaRQeK72STBZDsxd2QmHFqIdvEO9dfGOUmENZeBnIGX32C6PqS6&account_id=1&upload_file=C%3A%5Cfakepath%5Cdocument.pdf&folder_id=

Adam, any idea ?? Can i write up this URL or write how to pass it using CURL and POST, so i can test this in the browser ?
 

adam

Administrator
Staff member
Dec 5, 2009
2,043
108
63
See the following url as an example:

https://stackoverflow.com/questions/15200632/how-to-upload-file-using-curl-with-php

You should be able to do this:
Code:
$file_name_with_full_path = '/my/file/path/on/server/file.txt';
$target_url = 'https://www.website.com/api/v2/file/upload';

if (function_exists('curl_file_create')) { // php 5.5+
    $cFile = curl_file_create($file_name_with_full_path);
} else { // 
    $cFile = '@' . realpath($file_name_with_full_path);
}

$post = array('access_token' => 'xxx', 'account_id' => '1', 'upload_file'=> $cFile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
print_r($result);
curl_close($ch);
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
Thanks Adam, it may work now. I had one of the parameters incorrect.
I will give it a try today or tomorrow and will update here.
 

dgogoasa

Member
Jul 26, 2018
32
6
8
Hi there,

I am trying to develop a software for file upload using the API provided in this script and i am having troubles with file upload API.

I dont know how to specify the file path in the "upload_file=" parameter. I have tried full path, relative path, etc but no luck.

When i use the testing tool, it gives me:
upload_file=C%3A%5Cfakepath%5Cfilename.txt and i understand it is trying to say C:\fakepath\filename.txt but I am not sure what this fakepath is ?

Any ideas anybody ? Thanks in advance.

I am pretty much in the same boat.. or worse. I can't get further than authorize. When I want to use the token and id I always get "Could not validate access_token and account_id, please reauthenticate or try again ". And I run authorise again, I get new access_token and account_id with the same result.

Trying the test toll from the Admin area I get a different contradiction. I NEED TE PARENT FOLDER ID -"response": "Please provide the folder_id param.", But the documentation tells me another story:
Returns a list of folders and files within the passed parent_folder_id. If this value is blank the root folder/file listing is returned.

I totally agree that using those hidden ids for api is a very bad solution if different applications (people) want to use the API for sharing files.