I’m editing a script my coworker wrote that had a minification endpoint used. That endpoint went down so I’m adapting it to use this one, only I’m getting a 401 error everytime. I’m able to get a return from Postman on Chrome, but here is the snippet that is attempting to use your resource:
// $type is either ‘javascript’ or ‘css’ and $content is the JS or CSS
public static function miniFile($type, $content) {
$url = ($type == 'javascript' ? 'https://minify.p.mashape.com/js' : 'https://minify.p.mashape.com/css');
$ch = curl_init();
$parsed_type = ($type == 'javascript' ? 'script' : 'css');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "X-Mashape-Key: ysFHihoslEmshwLoMlD6iJTQ03GBp1RUwDcjsnyulsoyqNQ9o0"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array($parsed_type => $content));
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
Is there some sort of redirect in the API call or something I’m just plain overlooking? Thanks for any help you can give (couldn’t use the library you did b/c the machine is only running 5.2.6)
Join in the discussion - add comment below: