codeigniter - curl response showing nothing using within php -
codeigniter - curl response showing nothing using within php -
i trying info url using curl. i've made recursive function this. info , problem facing when no result found against curl call, page show me nothing, blank page shown.. no error @ all. i've used var_dump() testing response. found nothing.
here recursive function
function recursive_get_scrap($offset, $page_size, $urls, $original_array){ ini_set('max_execution_time', 1800); $of_set = $offset; $pg_size = $page_size; $off_sets = 'offset='.$of_set.'&page_size='.$pg_size.''; $url = $urls.$off_sets; $last_correct_array = $original_array; $ch1 = curl_init(); // disable ssl verification curl_setopt($ch1, curlopt_ssl_verifypeer, false); // homecoming response, if false print response curl_setopt($ch1, curlopt_returntransfer, true); curl_setopt($ch1, curlopt_header, 0); curl_setopt($ch1, curlopt_followlocation, 1); curl_setopt($ch1, curlopt_url,$url); // execute $result2 = curl_exec($ch1); $info = curl_getinfo($ch1); if(curl_errno($ch1)) { echo 'error:' . curl_error($ch1); //return $last_correct_array; } // closing curl_close($ch1); if(!$result2 || strlen(trim($result2)) == 0 || $result2 == false){ echo 'no array'; } if(isset($result2) && !empty($result2)){ echo 'in recursive function <br>'; $a1 = json_decode( $original_array, true ); $a2 = json_decode( $result2, true ); $temp_array = array_merge_recursive($a1, $a2 ); $last_correct_array = $temp_array; $offset += 100; $page_size = 100; recursive_get_scrap($offset, $page_size, $urls, json_encode($last_correct_array)); } }
now want if noting against curl phone call no array
message should displayed.
use alternative curl_setopt():
curl_setopt($ch, curlopt_returntransfer, true);
this create curl_exec homecoming info instead of outputting it.
to see if successful can check $result ,
curl_error().
php codeigniter curl
Comments
Post a Comment