插入带有类别的候选者 + BullHorn [英] Insert candidate with categories + BullHorn

查看:26
本文介绍了插入带有类别的候选者 + BullHorn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PHP 通过 REST API 在 Bullhorn 中保存和更新候选人.
我从 BullHorn 加载了一个候选人,我的类别以这种方式显示:

I'm trying to save and update a candidate in Bullhorn through the REST API with PHP.
I've loaded a candidate from BullHorn and my categories are shown this way:

["categories"]=>
object(stdClass)#632 (2) {
  ["total"]=>
  int(2)
  ["data"]=>
  array(0) {
  }
}
["category"]=>
object(stdClass)#654 (1) {
  ["id"]=>
  int(1123135)
}

我可以看到我的 id 等于 1123135.但是我怎么知道这些是哪些类别呢?我在 BullHorn 中选择了两个类别,我的 ID 现在是 1123135... .我有诸如电子营销专家、数据科学、..."之类的类别.

I can see that my id is equal to 1123135. But how can I know which categories these are? I've selected two categories in BullHorn and my id is now 1123135... . I have categories like "E-marketing Expert, Data Science, ...".

但是如何根据用户的选择更新这些类别?

But how can I update these categories based on the user's selected choices?

推荐答案

Bullhorn 中的类别与大多数其他实体类似.这就是我的做法

Categories in Bullhorn are similar to most other entities. This is the way I do it

function BHGetCategoryData($entity_type, $entity_id) {

    $url = $_SESSION['restUrl'].'entity/'.$entity_type.'/'.$entity_id.'?BhRestToken='.$_SESSION['BhRestToken'].'&fields=id,name';

    $options = array( 
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HEADER         => false,    
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_AUTOREFERER    => true,    
        CURLOPT_CONNECTTIMEOUT => 120, 
        CURLOPT_TIMEOUT        => 120,      
        ); 

    $ch  = curl_init( $url ); 
    curl_setopt_array( $ch, $options ); 
    $data = curl_exec( $ch ); 

    $obj = json_decode($data, true);

    curl_close( $ch ); 

    return $obj;

}

function BHQueryCategory() {

    $url = $_SESSION["restUrl"]."/query/Category?where=enabled=true%20AND%20id>1&fields=id,name&orderBy=id&count=100&BhRestToken=".$_SESSION["BhRestToken"];


    $options = array( 
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HEADER         => false,    
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_AUTOREFERER    => true,    
        CURLOPT_CONNECTTIMEOUT => 120, 
        CURLOPT_TIMEOUT        => 120,      
        ); 

    $ch  = curl_init( $url ); 
    curl_setopt_array( $ch, $options ); 
    $data = curl_exec( $ch ); 

    $obj = json_decode($data, true);

    return $obj;


}

// This dumps a list of categories
var_dump(BHQueryCategory());

$entity_id= 1123135;
$entity_type='Category';

// This will query one category for the name and id
var_dump(BHGetCategoryData($entity_type, $entity_id));

这当然假设你有你的休息网址和休息令牌以及所有这些东西.

This of course assumes that you have your rest url and rest token and all that stuff taken care of.

由于动态提取所有类别的时间延迟,我可能建议您下载完整列表并在客户端填充它 - 而不是每次要填充下拉列表时都调用查询.

Because of time delays in dynamically pulling all your categories, I would probably suggest that you download the full list and populate it client side - rather than calling the query every-time you want to populate a dropdown.

这里还有一个令人困惑的地方.有类别"可以作为单个值写入候选人记录.还有一个Categories",它是一个To-Many"的关系,不能和主实体一起写,必须单独调用.下面是一个可以做到这一点的函数.

Also here is a confusing bit. There is "Category" which can be written as a single value to a Candidate record. There is also "Categories" which is a "To-Many" relationship and cant be written with the main entity, it must be called separately. Below is a function that will do that.

function BHCreateCandidateToMany($candid,$codegroup,$codestring) {

$url = $_SESSION['restUrl'].'entity/Candidate/'.$candid.'/'.$codegroup.'/'.$codestring.'?BhRestToken='.$_SESSION['BhRestToken'];

echo $url;


$options = array( 
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_HTTPHEADER => Array("Content-Type: application/json"),
    CURLOPT_CUSTOMREQUEST => "PUT", 
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_AUTOREFERER    => true,    
    CURLOPT_CONNECTTIMEOUT => 120, 
    CURLOPT_TIMEOUT        => 120,      
  ); 

$ch  = curl_init( $url ); 
curl_setopt_array( $ch, $options ); 
$data = curl_exec( $ch ); 

$obj = json_decode($data, true);

curl_close( $ch ); 

return $obj;
}

文档位于此处 - http://developer.bullhorn.com/documentation/rest-api-1-1-update

(请根据需要整理代码 - 只是一个草稿,让您继续前进)

(Please tidy up the code as needed - just a rough draft to get you on your way)

这篇关于插入带有类别的候选者 + BullHorn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆