onlyoffice : How to retrieve document after conversion - php

I'm using onlyoffice to convert a file from docx to pdf (Documentation here : https://api.onlyoffice.com/editors/conversionapi).
I use curl to execute the example, and it works. I get the file url back, but the only issue is that when I try using this url (in a browser or downloading with file_get_contents), I have a 403 error.
There is nothing in the documentation that speak about the next steps post conversion, so I was wondering if someone could give me a hint. Is there an api method undocumented or something like that ?
Thanks

I get the file url back, but the only issue is that when I try using
this url
Please make sure that you use the link with all parameters. secure_link should also be included into the download link. If that doesn't help send us the link that you get.

The url in the xml back is sent back with html characters in it.
htmlspecialchars_decode on the url resolved my issue.

Related

URL being re-encoded?

I have a few links that look like this:
https://www.example.com/find?category=food%20%26%20drink
Clicking on the link should take me to a page where I can GET the variable, and it SHOULD read "food & drink".
However, when I click the link, it takes me to this url instead:
https://www.example.com/find?category=food%2520%2526%2520drink
the variable reads: food%20%26%20drink.
If I paste the first url into the search-bar directly, it works fine. But if I click on it as a link, then it gets re-encoded somehow.
Any idea how to get it to read "food & drink" even though it comes from a different page?
many thanks in advance!
Realized the links were written as http instead of https.
Consequently, they were being re-written by the htaccess file to https when clicked, and also being re-encoded at the same time.
The link you have is double encoded. The possible solution to this would be
Find line of code where the link getting encoded again and make suer not encode if encoded already. Couple of examples are given here Click Here
If there is no way you can change the code form where the URL is getting generated, then you have to use urldecode twice to parse the url params
<?php
$query = "https://www.example.com/find?category=food%2520%2526%2520drink";
$param = explode("=", $query);
print_r(urldecode(urldecode($param[1])));
?>
Hope this helps!

How to access url after # in php

I am trying to pass some parameters after # in the url like http://developer.rohitkhatri.com/test.php#embed=sdkhfjshdkfhhjk, But I don't know how to access it, I tried many solution from the stackoverflow, here are some examples what I've tried:
$_SERVER['REQUEST_URI'] gives me /test.php
$_SERVER['QUERY_STRING'] gives empty string
$_SERVER['HTTP_REFERER'] gives empty string
also tried printing the whole $_SERVER array but I did not find anything useful.
Any help is appreciated.
Well, there's no way to achieve this, because the part you are trying to access using the php, never goes to the server, what you can do is, just grab the part using the javascript and send it the the server.
Like there can be a middle page, which will redirect to the final url, and while redirecting, It can grab the part after # and send it using ajax.
The browser doesn't send anything that comes after the hash(#) to the server because it is resolved within the browser. You can try by mentioned code.
$hash = '<script>document.write(document.location.hash)</script>';
echo $hash;
output :
//#embed=sdkhfjshdkfhhjk

Web service's URL works fine with "/" but not with "%2F"

I'm facing a strange behaviour while working with a web-service.
Most of the URLs send me back a correct json response even if I work with urlencode().
So, for example, if I use http://mywebservice/?q=json_themes_abc%2F254 or http://mywebservice/?q=json_themes_abc/254, I'll get the same response.
But, only for one type of request, http://mywebservice/?q=json_demarches/2808 works and not http://mywebservice/?q=json_demarches%2F2808.
It happens only with ?q=json_demarches requests.
Does someone have a clue? Is the problem in my side or their? I read something about turning on “AllowEncodedSlashes” directive in their Apache but wouldn't be a general issue with all their URL if so?
Thanks in advance.

Using PHP to read a page and return to client

I have a simple scenario where, I have a URL1 and a URL2 and I want that when I access URL1, i should get the contents with full headers and data of URL2.
I could use a redirect, but i want the browser should show URL1 as the url only. I am looking for a PHP code that can read the URL2 and return it back to the client with all the headers and data.
Thanks in Advance :)
If you are trying to get the whole HTML code you can use the file-get-contents function
More information about it can be found here : file-get-contents
If you only want to change the address in the user address bar you may use URL Rewriting techniques. It's easy when you have access to the .htaccess file.
This might be useful : url-rewriting-for-beginners
Note: this will only work if the url with the content is in your site, otherwise, the rewriting rule in the .htaccess file can't help you and you have to use the first method.

file_get_contents() in php - need to pass static parameters and it's not working

I have a simple file I have created:
<?php echo file_get_contents("http://occupancyadvantage.com/shortquiz.aspx?sid=234"); ?>
I can only get the file to render properly when I remove the parameters (well, when you say properly, I doubt you would consider that (http://occupancyadvantage.com/processfree.php -- the %# page.... is showing up) But I could care less about that.
I'm just trying to get a php file to load this aspx file with the ?sid=243 parameter on the end of it.
I don't have access to curl - I have a few weeks without the tech guy here and I'm not allowed to make that kind of an install w/o him... I do have access to the ini file here is what it does have. If something isn't on, I don't know what it is: http://occupancyadvantage.com/phpinfo.php
I've been killing myself with this and I just can't seem to figure it out. Besides punching babies I figured this place was the best option.
If you could please, try to spell out your responses the best you can, as being vague will probably just end up with me researching and asking more questions. I appreciate it.
This note from PHP's documentation on file_get_contents() might help:
If you're opening a URI with special characters, such as spaces, you
need to encode the URI with urlencode().
So that would be:
<?php echo file_get_contents(urlencode("shortquiz.aspx?sid=234")); ?>
If that doesn't work, maybe use the full URL? As in:
<?php echo file_get_contents(urlencode("http://your-site-here/shortquiz.aspx?sid=234")); ?>
You can't file_get_contents with parameters if it's a local file. Just like you can't actually open the file with the parameters in a text file, it doesn't make sense to F_g_c.
You can, if the aspx is http-able, use f_g_c(http:/...).
Otherwise, you'll have to use wget (there are nastier ways to do it such as exec, but don't use them unless you don't need security at all).
You are trying to open the file named shortquiz.aspx?sid=234 in the current working directory. I'm guessing there is no such file in the current working directory.
If you want to fetch the url that ends with shortquiz.aspx?sid=234, you can try this:
file_get_contents('http://example.org/shortquiz.aspx?sid=234');
Of course, replace "example.org" with the full host and path for this URL.
I ended up using an iFrame to do this. I don't know what I was thinking. Thank you for all of your time.

Categories