插入带有类别+扩音器候选人 [英] Insert candidate with categories + BullHorn

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

问题描述

我试图通过REST API使用PHP来保存和更新扩音器的候选人。结果
我从扩音器加载的候选人,我的类别显示是这样的:

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 。但我怎么能知道这些都是哪些类别?我选择两大类扩音器,我的ID是现在的 1123135 ...。我有类别,如 E-营销专家,数据科学,... 的。

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?

推荐答案

在扩音器类别是类似于大多数其他实体。这是我做的方式。

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.

另外这里是一个令人困惑的一点。有类型,它可以写为一个单一的值,以候选记录。也有分类,这是一个一对多的关系,并不能与主实体被写入,必须单独调用。下面是会做一个函数。

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 /文档/ REST的API-1-1更新

(请根据需要收拾code - 只是一个粗略的草稿,让你对你的方式)

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

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

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