I have a site written in CakePHP which needs to download files from Veeva 
Vault. I inherited this authentication function from someone else which is 
supposed to return a session id from Veeva, but it returns false on 
curl_exec() when it should return true. I was told the function worked with 
a test file outside CakePHP so I'm thinking its something Cake related.

private function Auth(){
    try {

    $url = self::VVURL . '/auth?username=' . self::VVUSERNAME . '&password=' . 
self::VVPASS;

    $curl = curl_init($url);

    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: 
application/json;charset=UTF-8"));
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, null);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

    $json_response = curl_exec($curl);

    if ($json_response != true) {
        throw new Exception (curl_error($curl), curl_errno($curl));
    }
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    if($status != 200)
    {
      die('Error:  call to URL $url failed with status "' . $status .'", 
response "' . $json_response. '", curl_error "' . curl_error($curl) . '", 
curl_errno "'  . curl_errno($curl). '"');
    }
    else 
    {
      //Enable following line to DEBUG
      //print_r($json_response);
    }

    curl_close($curl);

    $return = json_decode($json_response);
    foreach($return as $k => $v)
    {
      if($k == 'sessionId')
        $this->sessID = $v;
    }

    return $this->sessID;

    }
    catch(Exception $e){
        trigger_error(sprintf(
        'Curl failed with error #%d: %s',
        $e->getCode(), $e->getMessage()),
        E_USER_ERROR);
    }}

curl_init($url) returns *resource(148, curl)* . I don't know if that's 
right or not.

curl_getinfo($curl, CURLINFO_HTTP_CODE) returns 200, so I know that's good.

curl_exec($curl) returns false.

The catch returned:

Fatal Error Error: Curl failed with error #56: Problem (2) in the 
Chunked-Encoded data
File: C:\wamp\www\content\app\Vendor\veeva\veeva.php
Line: 109 Notice: If you want to customize this error message, create 
app\View\Errors\fatal_error.ctp

Unfortunately I can't seem to find any helpful Veeva documentation.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to