Influencer Search
getClient();
// Create a search query for YouTube influencers in tier 1 countries
$query = "SELECT channel_id, channel_name, subscriber_count, views, red_views, estimated_minutes_watched, " .
"estimated_red_minutes_watched, average_view_duration, playlist_starts, views_per_playlist_start, " .
"average_time_in_playlist, insight_playback_location_type, insight_traffic_source_type, device_type, " .
"day_of_week, operating_system, age_group, gender, ad_type, gross_revenue, ad_impressions, cpm, " .
"uploader_type, claimed_status " .
"FROM youtube_channels " .
"WHERE subscriber_count >= " . $minSubscribers . " " .
"AND location IN ('" . implode("','", $tier1) . "') " .
"AND ad_type = '" . $adType . "' " .
"AND uploader_type = '" . $uploaderType . "' " .
"AND claimed_status = '" . $claimedStatus . "' " .
"AND (";
for ($i = 0; $i < count($keywords); $i++) {
$query .= "keywords CONTAIN '" . $keywords[$i] . "' OR ";
}
$query = substr($query, 0, strlen($query) - 4); // remove the final OR
$query .= ") " .
"ORDER BY " . $sortBy . " " . $sortOrder;
// Run the search query
$report = $client->report($query);
$rows = $report->rows();
// Export the search results to a CSV file
function exportToCsv($rows) {
// Create a CSV file
$csv = "