I’m getting “Undefined property: Requests_Exception_Transport_cURL::$status_code” error and failed to solve it.
private function do_bulk_api_call( $endpoint, $data=array(), $version=0 ) {
if( !$this->cmcapi['status'] )
return false;
$final_api_data = $bulk_requests = array();
$options = get_option( 'cmcapi' );
$version = $version ? $version : $this->cmcapi['version'];
$bulk_url = $this->cmcapi['url'] . $version . $endpoint;
if( $data && is_array($data) ):
foreach ($data as $k => $chunk) {
// TEMP condition
// if( $k > 0 )
// continue;
$bulk_requests[] = array(
'type' => 'GET',
'timeout' => 90,
'url' => $bulk_url,
'headers' => array(
'X-CMC_PRO_API_KEY' => $this->cmcapi['key'],
),
'data' => array( 'id' => implode(',',$chunk) )
);
}
endif;
$requests = Requests::request_multiple( $bulk_requests );
foreach ($requests as $key => $response) {
if($response->status_code !== 200) {
continue;
}
$res_decoded = json_decode($response->body);
$this->kte_shipment_api_results[$key] = array();
$final_api_data = array_merge( (array) $final_api_data, (array) $response->data );
if( !$res_decoded->status->error_code && is_object($res_decoded->data) ){
$final_api_data = array_merge( (array) $final_api_data, (array) $res_decoded->data );
}
}
return $final_api_data;
}
By the way, this code is from other teammate and he is gone now so I cannot ask to him.