vincere-io / restful-api-support

5 stars 0 forks source link

Return output null when trying to get job list #24

Open sumitsinghwp opened 1 year ago

sumitsinghwp commented 1 year ago

It was working fine a few weeks ago but now I can't able to get data from API.

getting below result. Array ( [result] => [code] => 0 [content_type] => )

below is my code.

` class Kimit_Vincere {

    var $domain;

    function __construct()
    {
        $this->domain = "https://mydomain.vincere.io/";
    }

    function getData($start=0){
        $client_apikey = #######;
        $client_clientid =#######;
        $access_token =#######;
        $id_token = #######;

        $client = new OAuth2\Client($client_clientid, $client_apikey);
        $client->setAccessToken($access_token);

        $fields = array(
            'id',
            'job_summary',
            //'comment',
            'currency',
            'note',
            //'external_id',
            'job_title',
            'job_type',
            //'job_type_display',
            'employment_type',
            //'employment_type_display',
            'head_count',
            'open_date',
            'closed_date',
            'public_description',
            'internal_description',
            /*'contact_id',
            'contact_email',
            'contact_phone',
            'contact_linkedin',
            'contact_note',
            'contact_first_name',
            'contact_middle_name',
            'contact_last_name',
            'contact_first_name_kana',
            'contact_middle_name_kana',
            'contact_last_name_kana',
            'contact_job_title',
            'contact_company_id',
            */
            'contact',
            'pay_rate',
            'formatted_pay_rate',
            //'actual_salary',
            'contract_length',
            //'registration_date',
            /*'location_address',
            'location_district',
            'location_city',
            'location_country',
            'location_state',
            'location_id',
            'location_location_name',
            'location_post_code',
            'location_country_code',
            'location_nearest_train_station',
            'location_longitude',
            'location_latitude',*/
            'location',
            'industry',
            'fe',
            'sfe',
            'salary_type',
            'published_date',
            //'screening_questions',
            'salary_from',
            'salary_to',

            // added 20180918 mh
            'private_job',

            'formatted_salary_from',
            'formatted_salary_to',
            //'document',
            //'other_document',
            'hot_end_date',
            //'hot_job',
            //'contact_photo',
            //'contact_external_id'
        );

       // $fieldsString = implode(',',$fields);
        $fieldsString = 'job_title';

        //$response = $client->fetch($this->domain.'api/v2/job/search/?q=text:Floated%23',array(), OAuth2\Client::HTTP_METHOD_GET, array('id-token'=> $id_token, 'x-api-key'=> $client_apikey));
        $response = $client->fetch($this->domain.'api/v2/job/search/fl='.$fieldsString.';sort=created_date asc?start='.$start.'&limit=100&language=en',array(), OAuth2\Client::HTTP_METHOD_GET, array('id-token'=> $id_token, 'x-api-key'=> $client_apikey));
        echo $this->domain.'api/v2/job/search/fl='.$fieldsString.';sort=created_date asc?start='.$start.'&limit=100&language=en';
        print_r($response);

        if(array_key_exists('message',$response['result'])){

        nclegallog($response);

            if ($response['code'] == 401){

                //update tokens
                global $Kimit_Vincere_Auth;
                $Kimit_Vincere_Auth->refreshToken();

                return $this->getData();
            }

            // add something here that will let Catherine know something has gone wrong
        }

        $jobs = array();

        if(array_key_exists('result',$response) && array_key_exists('result',$response['result'])){
            $result = $response['result']['result'];
            $resultCount = count($result['items']);
            foreach($result['items'] as $jobItem){
                $jobs[] = $jobItem;
            }

            if($result['start'] + $resultCount < $result['total']){
                $jobs = array_merge($jobs, $this->getData($result['start'] + $resultCount));
            }
        }

        return $jobs;
    }`

Can you help me with what is wrong with me, please?