Beginning of socmed import
[disclosr.git] / admin / importGov2RegisterRSSFacebookTwitter.php
blob:a/admin/importGov2RegisterRSSFacebookTwitter.php -> blob:b/admin/importGov2RegisterRSSFacebookTwitter.php
<?php <?php
   
require_once '../include/common.inc.php'; require_once '../include/common.inc.php';
try {  
$server->create_db('disclosr-agencies'); $db = $server->get_db('disclosr-agencies');
} catch (SetteeRestClientException $e) { $rows = $db->get_view("app", "byName")->rows;
setteErrorHandler($e); $nametoid = Array();
  $accounts = Array();
  foreach ($rows as $row) {
  $nametoid[trim($row->key)] = $row->value;
} }
$db = $server->get_db('disclosr-agencies');  
createAgencyDesignDoc();  
   
// twitter https://docs.google.com/spreadsheet/fm?id=tsJVd9EYoAjbl014y3qMgWg.03918275400592898296.8568379511161083736&hl=en&fmcmd=5&gid=0 function extractCSVAccounts($url, $nameField, $accountField, $filter) {
// RSS https://docs.google.com/spreadsheet/fm?id=tbqjwIDHKHiVYF_glJ93GgA.03918275400592898296.8789688748524615194&authkey=CJDP-uQG&hl=en_GB&fmcmd=5&gid=0 global $accounts, $nametoid;
// facebook https://docs.google.com/spreadsheet/fm?id=tkcqoo9wrgzNWmoANuVhsBw.03918275400592898296.3040387705062056060&authkey=CKzl7r0I&hl=en_GB&fmcmd=5&gid=0 $request = Requests::get($url);
  $Data = str_getcsv($request->body, "\n"); //parse the rows
  $headers = Array();
  foreach ($Data as $num => $line) {
  $Row = str_getcsv($line, ",");
  if ($num == 0) {
   
  } else if ($num == 1) {
  $headers = $Row;
  //print_r($headers);
  } else {
  if (isset($Row[array_search($nameField, $headers)])) {
  $agencyName = $Row[array_search($nameField, $headers)];
  if (!$filter || $Row[array_search("State", $headers)] == "NAT") {
  if (!in_array(trim($agencyName), array_keys($nametoid))) {
  echo "$agencyName missing" . PHP_EOL;
  } else {
  // echo $Row[array_search($nameField, $headers)] . PHP_EOL;
  }
  }
  } else {
  //echo "error finding agency" . $line . PHP_EOL;
  }
  }
  }
  }
   
  // http://agimo.govspace.gov.au/page/gov2register/
  // twitter
  extractCSVAccounts("https://docs.google.com/spreadsheet/pub?key=0Ap1exl80wB8OdHNKVmQ5RVlvQWpibDAxNHkzcU1nV2c&single=true&gid=0&output=csv", "Agency/Body/Event", "", true);
  // RSS
  // https://docs.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0Ah41IAK0HzSTdGJxandJREhLSGlWWUZfZ2xKOTNHZ0E&output=csv
  // facebook
  //extractCSVAccounts("https://docs.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0Ah41IAK0HzSTdGtjcW9vOXdyZ3pOV21vQU51VmhzQnc&single=true&gid=0&output=csv","","");
   
/* /*
* http://australia.gov.au/news-and-media/media-release-rss-feeds * http://australia.gov.au/news-and-media/media-release-rss-feeds
* http://australia.gov.au/news-and-media/social-media/blogs * http://australia.gov.au/news-and-media/social-media/blogs
* http://australia.gov.au/news-and-media/social-media/twitter * http://australia.gov.au/news-and-media/social-media/twitter
* http://australia.gov.au/news-and-media/social-media/facebook * http://australia.gov.au/news-and-media/social-media/facebook
* http://australia.gov.au/news-and-media/social-media/youtube * http://australia.gov.au/news-and-media/social-media/youtube
* http://australia.gov.au/news-and-media/social-media/flickr * http://australia.gov.au/news-and-media/social-media/flickr
* http://australia.gov.au/news-and-media/social-media/apps http://www.harmony.gov.au/get-involved/app-downloads.htm http://www.em.gov.au/Resources/Pages/Before-the-Storm-phone-game.aspx * http://australia.gov.au/news-and-media/social-media/apps http://www.harmony.gov.au/get-involved/app-downloads.htm http://www.em.gov.au/Resources/Pages/Before-the-Storm-phone-game.aspx
* http://australia.gov.au/news-and-media/social-media/podcasts * http://australia.gov.au/news-and-media/social-media/podcasts
*/ */
?> ?>