mikeyF Report post Posted May 28, 2014 Hi,I would like to use the API with php. My installation is on windows and I cant make it work! As far as now : I got a "sync.conf" file but the command don't run the programme silently :"C:\Program Files (x86)\BitTorrent Sync>BTSync.exe /config sync.conf" i'm trying to check if it work on chrome, looking at localhost:8888/gui127.0.0.1:8888/gui And with a php wrapping of the API with wamp : "https://github.com/iGARET/BTSync-PHP" my sync.conf :{ "storage_path" : "./", "use_gui" : true, "webui" : { "listen" : "127.0.0.1:8888", //"login" : "<someusername>", //"password" : "<somepassword>", "api_key" : "API-KEY" }} index.php : <?php include("btsync.php"); $client = new BTSync(); $p = $client->getFolders(); var_dump($client); var_dump($p);?> Quote Share this post Link to post Share on other sites
RomanZ Report post Posted May 28, 2014 @mikeyF The WebUI is not available on Windows platform. Most likely your Sync is up and running (I tested your config in my lab - it is okay). To check that it is operational:1. check if the btsync.exe process is running2. Run a test API command from your browser, for example - http://127.0.0.1:8888/api?method=get_folders Quote Share this post Link to post Share on other sites
mikeyF Report post Posted May 28, 2014 Are you on windows?Because i ask the support team they answered : Dear user,Unfortunately, API for Windows can't access it yet. So far only for Linux. We will consider a way to enable it for Windows as well.Best regards,*Sync Support Team. Quote Share this post Link to post Share on other sites
RomanZ Report post Posted May 28, 2014 @mikeyF Yes, I did the test on Windows. You've got a correct answer from Sync Support. They answer that API for windows can't access it ("it" = URL http://127.0.0.1:8888/gui), which is pretty much the same as I told. If you see some contradiction here - please elaborate, so I can explain it in a more detailed way. Quote Share this post Link to post Share on other sites
mikeyF Report post Posted May 28, 2014 When I try to access to :http://127.0.0.1:8888/api?method=get_folders It does not work. So i imagined that it was the same as using the API.But if it work for you wy it doesn't for me? I'm jealous! Dit it work for you when you do that:"C:\Program Files (x86)\BitTorrent Sync>BTSync.exe /config sync.conf" (it does not for me again) If you have any idea, I take it. My version is 1.3.105 and I use windows 7 family edition. Quote Share this post Link to post Share on other sites
RomanZ Report post Posted May 28, 2014 @mikeyF Yes, I'm starting btsync with pretty much same command as you do from console. I did a test on Win7 x64 and WinXP x86 using your config file (except the fact that I've replaced API-KEY with my API key). The URL http://127.0.0.1:8888/api?method=get_folders should return an empty JSON data which is going to look like 2 empty square brackets:[ ]So, just to make sure that simple stuff is covered:1. What do you mean under "non-working"? Are you getting a timeout or some other error message?2. After you run the command line - do you see BTSync icon in the system tray appear? Is the btsync process seen in the tree or it exits immediately \ after some time?3. Is there any other instance of BTSync running simultaneously?4. Do you place your API key instead of "API-KEY" (I know it sounds very simple - just want to make sure you check this as well)? Don't be jealous, we'll do our best to make your API working Quote Share this post Link to post Share on other sites
mikeyF Report post Posted May 28, 2014 I investigate that point. On the task manager it appears and get quickly killed, without any message.I believe it act like there is an other instance of BTSync active. Before I try the command line i quite BTSync with a right click and quit on the process-bar icon. As it start running from the command line with the configuration file the memorie used (into the task manager) is around 2 000k but when i run it without the configuration file (still with command line) it use about 25 000k. So he may not like my conf file or there is a lock file (like this F***g firefox on linux when it crash !!) How does it act if you put a wrong API-KEY ? (yes i change the "API-key" nothing is too simple) Quote Share this post Link to post Share on other sites
RomanZ Report post Posted May 28, 2014 @mikeyF There is a known issue with API for Windows: it never shows the error code / text when something is going wrong. The only difference I see between your environment and mine is the API key. ...which makes me think that something is wrong with your API key. I suggest you sending me your whole config file unchanged (yes, with API key untouched - it won't be considered as terms violation as I'm BitTorrent employee, do not worry) and i'll check it in my lab. Send the file, don't copy-paste the content to make the test clean. Use syncapp@bittorrent.com e-mail address, note this forum topic in message body for ease of search. Quote Share this post Link to post Share on other sites
mikeyF Report post Posted May 28, 2014 it won't be considered as terms violation as I'm BitTorrent employee That is exactly what a pirate would have said !!the object of the mail : [install And Use Api On Windows] Quote Share this post Link to post Share on other sites
RomanZ Report post Posted May 29, 2014 @mikeyF That is exactly what a pirate would have said !!Well... why did you sent the key then ? Anyway, I have some good news for you.1. Your API key is okay and not revoked.2. Your config with API key worked just fine in my environment.3. Thanks to one of our support engineer (Helen) I have a good guess that I know why it is not working for you. It is very likely that you are running btsync.exe right from the "program files" folder - which is protected by UAC. While your config tells it to put all the data directly into the same folder is binary - OS prevents that and btsync simply can't run further. So - either move your binary from the program files, or just put your storage folder in some other location. Here is a sample config which is going to work:{ "storage_path" : "C:\\MyAPIStorage", "use_gui" : true, "webui" : { "listen" : "127.0.0.1:8888", //"login" : "<someusername>", //"password" : "<somepassword>", "api_key" : "<your_API_key" }} 3 small notes:1. MyAPIStorage folder must exist2. When putting paths for Windows OS - use backslashes as component delimiters3. As backslash is a special character in JSON - you have to escape it (put twice). Quote Share this post Link to post Share on other sites
mikeyF Report post Posted May 29, 2014 It was the path ! It works just fine now ! Thanks Quote Share this post Link to post Share on other sites