1

I am using following php library for to work with Taleo

Taleo : http://www.oracle.com/us/products/applications/taleo/overview/index.html

PHP library : https://github.com/Polzme/Taleo

Taleo REST API documentation: http://www.oracle.com/technetwork/documentation/default-1841567.html

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 library 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.

4

1 回答 1

1

这是示例,一些我如何使它工作的方法

<?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();
    echo $json  = Curl_file_upload('https://xxx.xxx.taleo.net/ldd01/ats/api/v1/object/candidate/58/resume', $params);
}
于 2014-11-13T14:29:47.590 回答