Taleo icon indicating copy to clipboard operation
Taleo copied to clipboard

How can I upload resume for candidate using library?

Open bkvaiude opened this issue 11 years ago • 8 comments

Thanks for wonderful library.

POST /candidate/{id}/resume

I wanted to use above API for my project I wanted to create candidate and upload resume for them using api.

I went through the code but i didn't found any file or any code line, which is related to resume or attachment Can you please help me with simple example with library or without library??

bkvaiude avatar Nov 10 '14 17:11 bkvaiude

Finally here is the working example, I have manage to run it successfully, can you please integrate with library code

<?php
        function getCurlValue($filename, $contentType, $postname)
        {
            // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
            // See: https://wiki.php.net/rfc/curl-file-upload
            if (function_exists('curl_file_create')) {
                return curl_file_create($filename, $contentType, $postname);
            }

            // Use the old style if using an older version of PHP
            $value = "@{$filename};filename=" . $postname;
            if ($contentType) {
                $value .= ';type=' . $contentType;
            }

            return $value;
        }

    function Curl_file_upload($url, $postData)
    {
        $filename = '/Users/bhushan/Downloads/resume.pdf';
        $cfile = getCurlValue($filename,'application/pdf','resume.pdf');

        //NOTE: The top level key in the array is important, as some apis will insist that it is 'file'.
        $data = array('file' => $cfile);

        $ch = curl_init();
        $options = array(CURLOPT_URL => $url,
                     CURLOPT_RETURNTRANSFER => true,
                     CURLINFO_HEADER_OUT => true, //Request header
                     CURLOPT_HEADER => true, //Return header
                     CURLOPT_SSL_VERIFYPEER => false, //Don't veryify server certificate
                     CURLOPT_POST => true,
                     CURLOPT_COOKIE =>"authToken=".$_SESSION['authToken'],
                     CURLOPT_POSTFIELDS => $data
                    );

        curl_setopt_array($ch, $options);
        $output = $result = curl_exec($ch);
        $header_info = curl_getinfo($ch,CURLINFO_HEADER_OUT);
        $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
        $header = substr($result, 0, $header_size);
        $body = substr($result, $header_size);
        curl_close($ch);
        return $output;
    }

    function curl_call($url, $postData)
    {

        $ch = curl_init();  
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
        curl_setopt($ch,CURLOPT_HEADER, false); 
        //curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
        $output=curl_exec($ch);
        curl_close($ch);
        return $output;
    }

    if(!isset($_SESSION['authToken']) || empty($_SESSION['authToken']))
    {
        $data = array('orgCode' => 'xxxx', 'userName' => 'xxxx', 'password' => 'xxx');
        echo $json = curl_call('https://xxx.xxx.taleo.net/ldd01/ats/api/v1/login', $data);
        $json = json_decode($json, true);
        if(isset($json['response']['authToken'])) $_SESSION['authToken'] = $json['response']['authToken'];
    }
    else if(isset($_SESSION['authToken']) && !empty($_SESSION['authToken']))
    {

        $params = array(
      'openedDate_from' => "2010-05-05", 
      'duration' => "FULLTIME",
      'cws' => 1);
        echo $json  = Curl_file_upload('https://xxx.xxx.taleo.net/ldd01/ats/api/v1/object/candidate/58/resume', $params);
    }

bkvaiude avatar Nov 13 '14 14:11 bkvaiude

This is very interesting !

The thing is that you are using Curl which is not available everywhere.

Could you try to update your example and use Guzzle instead ?

Thanks !

drupol avatar Nov 13 '14 16:11 drupol

Hi, Great library. I'm trying to build something similar in RoR, just wondering how you tested the API integration, did you have to partner with Oracle to get a username or did you have an account already?

shiba4life avatar Apr 03 '15 19:04 shiba4life

Yes. My client provide me required credentials and API keys for integration.

On Sat, Apr 4, 2015 at 12:36 AM, Tom Tang [email protected] wrote:

Hi, Great library. I'm trying to build something similar in RoR, just wondering how you tested the API integration, did you have to partner with Oracle to get a username or did you have an account already?

— Reply to this email directly or view it on GitHub https://github.com/Polzme/Taleo/issues/4#issuecomment-89393028.

Bhushan Vaiude

bkvaiude avatar Apr 04 '15 05:04 bkvaiude

Same for me.

drupol avatar Apr 04 '15 06:04 drupol

Here is the solution which I have implemented using CURL

http://stackoverflow.com/questions/26849265/php-taleo-library-update-a-candidate-resume/26911187#26911187

On Sat, Apr 4, 2015 at 11:38 AM, Pol Dellaiera [email protected] wrote:

Same for me.

— Reply to this email directly or view it on GitHub https://github.com/Polzme/Taleo/issues/4#issuecomment-89510249.

Bhushan Vaiude

bkvaiude avatar Apr 04 '15 06:04 bkvaiude

Sadly it's not included in the PHP library, why not make a patch ?

drupol avatar Apr 04 '15 07:04 drupol

Actually client discontinue with idea of integration of API, so after that I didn't look at it much. Just for demonstration, I have created sample app using the API. But any way I have used all api from doc using curl, not using this app

On Sat, Apr 4, 2015 at 12:31 PM, Pol Dellaiera [email protected] wrote:

Sadly it's not included in the PHP library, why not make a patch ?

— Reply to this email directly or view it on GitHub https://github.com/Polzme/Taleo/issues/4#issuecomment-89514453.

Bhushan Vaiude

bkvaiude avatar Apr 04 '15 07:04 bkvaiude