Question

I am using crocdoc in php https://github.com/crocodoc/crocodoc-php

i downloaded the files in my local i had my API TOKEN so i pasted it there but it doesnt seems to work and throws error shown below for all 15 examples

can any one help me here

This is the error here which i am getting on using above github code with my Token

Example #1 - Upload Form W4 from the IRS by URL.
  Uploading... failed :(
  Error Code: curl_exception
  Error Message: Crocodoc: [curl_exception] Crocodoc::_request

{"curl_errno":60,"curl_error":"SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"}



Example #15 - Delete the second file we uploaded.
  Deleting... failed :(
  Error Code: curl_exception
  Error Message: Crocodoc: [curl_exception] Crocodoc::_request

{"curl_errno":60,"curl_error":"SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"}

To check i am using the crocodoc API properly i wrote my own code

this is the error i am getting in my own code

::::OUTPUT::::
{"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}
checking status of : {"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}

Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Curl error no: 60
out put for docurlGet is : 
bool(false) status is : 
Viewing the Document : {"uuid": "300dc39d-e82b-4d92-a701-b1f376600b96"}

this is my code (i am sorry if i am not suppose to paste the whole code but could not understand the whole issue so i am just giving whole code )

<?php

$myToken='gSqV0PpEZhvJfLxQTcuMmoty';
$frameUrl='https://crocodoc.com/api/v2/document/upload';
 $api_url = 'https://crocodoc.com/api/v2/';
//curl "https://crocodoc.com/api/v2/document/upload" --data "token=${API_TOKEN}&url=http://web.crocodoc.com/files/test-simple.pdf"
$param='token='.$myToken.'&url=http://web.crocodoc.com/files/test-simple.pdf';

 //curl command 

    $ch = curl_init(); 
                @curl_setopt($ch, CURLOPT_HEADER, 0);
                @curl_setopt($ch, CURLOPT_HTTPHEADER,  array('Accept: application/json', 'X-HTTP-Method-Override: POST'));
                @curl_setopt($ch, CURLOPT_POST, 1);
                @curl_setopt($ch, CURLOPT_URL, $frameUrl);   
                @curl_setopt($ch, CURLOPT_POSTFIELDS,$param);

                @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
                curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
                curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
                $uuids = curl_exec($ch);
 echo $uuids;
 echo "<br>";
 echo " checking status of : ", $uuids."<br>";
$status =getStatus($uuids,$api_url,$myToken);
//curl 'https://crocodoc.com/api/v2/document/status?token=F6JOdArWGKmDRlfPQcZna71x&uuids=d5ea0542-baaf-46a1-835c-685a86e70e14'
echo " status is : ", $status."<br>";


echo " Viewing the Document  : ", $uuids."<br>";

function getStatus($uuids,$api_url,$myToken){


            $isSingleUuid = is_string($uuids);

                $obj  = json_decode($uuids);
                $my_uuid= $obj->uuid;

                $url = $api_url.'document/status';

        $token = $myToken;

        $dataStr = '?token='.$token.'&uuids='.$my_uuid;

        $output = my_doCurlGet($url, $dataStr);
               var_dump($output); 
        return $output;


}




        function my_doCurlGet($url, $dataStr) {
        //var_dump($url.$dataStr);
        //  var_dump($dataStr);exit;

        //
        $ch1 = curl_init();

        @curl_setopt($ch1, CURLOPT_HEADER, 0);
        @curl_setopt($ch1, CURLOPT_HTTPHEADER,  array('Accept: application/json', 'X-HTTP-Method-Override: POST'));
        @curl_setopt($ch1, CURLOPT_POST, 1);
        @curl_setopt($ch1, CURLOPT_URL, $url.$dataStr);
        @curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch1);

        if(curl_exec($ch1) === false)
        {
        echo "<br>".'Curl error: ' . curl_error($ch1);
        }
        else
        {
        echo "<br>".'Operation completed without any errors'."<br>";
        }
        //var err_no=curl_errno()
        if(curl_errno($ch1))
        {
        echo "<br>".'Curl error: ' . curl_error($ch1);
        echo "<br>".'Curl error no: ' . curl_errno($ch1);
        }


        echo "<br>". "out put for docurlGet is : $output"."<br>";


        return $output;
        }


  if (curl_errno($ch)) {    
    print 'An curl error has occurred.';
 exit;
  }
  //var_dump($uuids);
  curl_close($ch);        
  return $uuids;
?> 

Thanks for all your help

Was it helpful?

Solution 2

Found the answer

First of all i did enable curl and SSL for beginning but it was not working

i even changed my Localhost name to myHost but it still did not work

so I made few changes in crocodoc.php file which i downloaded from crocodoc api library

CROCODOC PHP LIBRARY

I added this lines and IT WORKED :):):) Thank you all, hope this helps someone else as well.

if(($_SERVER['SERVER_NAME'] == 'myHost') && ($_SERVER['SERVER_ADDR'] == '127.0.0.1') && ($_SERVER['HTTP_HOST'] == 'myHost')) {
            $options[CURLOPT_SSL_VERIFYPEER]=false;
        }

OTHER TIPS

Curl probably isn't properly configured with a CA bundle, or the configured CA bundle does not include Crocodoc's CA cert.

Check out this answer for more info.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top