Hi,
I keep getting this error when I do a get, and I’m getting no response with my post:
Missing Mashape application key. Go to http:\/\/docs.mashape.com\/api-keys to learn how to get your API application key.
I’ve put in my application key, I got it, put it in, should be good.
I am using the pdf2jpg api.
I’m trying to convert the file:
http://patersonconnect.com/_img/text.pdf (you can see it’s there).
I’m running this script from the same folder. You can run it yourself:
http://patersonconnect.com/_img/x1.php
here’s what’s in it:
<?php
// Report all PHP errors
error_reporting(-1);
// Same as error_reporting(E_ALL);
ini_set(‘error_reporting’, E_ALL);
require_once ‘src/Unirest.php’;
echo '<br>start: ';
// These code snippets use an open-source library. http://unirest.io/php
$response = Unirest\Request::post(“https://pdf2jpg-pdf2jpg.p.mashape.com/convert_pdf_to_jpg.php”,
array(
“X-Mashape-Key” => “PLaDHzXwxGmshhSW3WkYtgOvrrKEp1ZLmZ5jsnGFsdeo8a0YJJ”
),
array(
“pdf” => Unirest\file::add(“text.pdf”),
“resolution” => 300
)
);
echo json_encode($response);
?>
I’m not getting any errors, just nothing.
I also have a second script which runs the “get” here. I can’t put in the necessary response key’s from the first script as they are not appearing, but I still shouldn’t be getting an issue with the API key, right?
<?php
echo ‘response:<br>’;
require_once ‘src/Unirest.php’;
// These code snippets use an open-source library. http://unirest.io/php
$response = Unirest\Request::get(“https://pdf2jpg-pdf2jpg.p.mashape.com/convert_pdf_to_jpg.php?id=8084&key=8f1c364d1be4e0a951e67e652cc25325e0dbdff7”,
array(
“X-Mashape-Key” => “PLaDHzXwxGmshhSW3WkYtgOvrrKEp1ZLmZ5jsnGFsdeo8a0YJJ”,
“Accept” => “application/json”
)
);
var_dump($response);
?>
You can run this script for yourself here:http://patersonconnect.com/_img/x2.php
Why would be getting this error? It shouldn’t be an SSL thing, right?
Please help.
Thank you.
चर्चा में शामिल हों - नीचे टिप्पणी जोड़ें:
Oh, okay. No worries about this 2/3 thing. The API is a pure REST API, it relies only on HTTP and JSON. You can use Unirest 2 or 3 or even another library you prefer. The API will continue to work whatever you choose.
And regarding possible API update: whatever happens, backward compatibility will be preserve. What works today will still work tomorrow.
Yeah, the forum here distorted what I pasted. The comment line is not an issue.
I’ve actually gotten this to work by downloading a version of 2.x somewhere, so I’m kinda good, but haven’t had a chance to try with 3.0. I appreciate the code you sent, but my work was time sensitive and I had to implement the solution by using 2.x which is now running smoothly.
I’m sure I’ll try with 3.0 at some point, but as it’s not pressing at the moment, I’m not sure when. My concern is that the API will be updated at some point so that it will stop working with 2.x and I’ll have to scramble to fix the code. Is this something that’s likely to happen, or should I be good indefinitely with 2.x?
Thanks again.
I used the latest, so Unirest 3. But Unirest 2 should work just fine, too.
Silly question: since your script doesn’t output anything right now, are you sure it actually works? For example, if you put a final
echo "Done\n";
at the end, is “Done” displayed? I suppose this is just due to the Mashape text editor, but in your question above it looks like the actual API request is on the same line as a comment… so it looks like it is commented out.Thanks for your response.
Are you using UniRest 2.x or 3.0?
I wrote a PHP script and here is what it returns:
It prints:
So basically the data is here.
The code is slightly different of what Mashape generates because the UniREST API evolved.
Does this help?