PageRenderTime 56ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/www/mixi_profile.php

https://github.com/komagata/plnet
PHP | 74 lines | 57 code | 15 blank | 2 comment | 3 complexity | 12c5e9e5120d252016a051e0c2a7ec94 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. require_once dirname(dirname(__FILE__)).'/webapp/config.php';
  3. define('RSS_MAX', 16);
  4. if (!defined('MIXI_CACHE_DIR')) define('MIXI_CACHE_DIR', '/tmp/');
  5. require_once 'FOAFWriter.php';
  6. require_once 'phpMixi.class.php';
  7. $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
  8. $mixi =& new PHP_Mixi('komagata@p0t.jp', 'komagata', true);
  9. $mixi->cache_dir = MIXI_CACHE_DIR;
  10. $mixi->login();
  11. $profile = $mixi->parse_show_friend($id);
  12. $profile = array_e2u($profile);
  13. //print_r($profile);
  14. $friends = $mixi->get_all_friend($id);
  15. $friends = array_e2u($friends);
  16. //print_r($friends);
  17. $blog_home = 'http://mixi.jp/show_friend.pl?id=';
  18. $tag_uri = SCRIPT_PATH.'tag/';
  19. $mixi_foaf = SCRIPT_PATH.'?id=';
  20. $writer =& new FOAFWriter();
  21. $writer->setProfile(array(
  22. 'nick' => $profile['name'],
  23. 'bio' => $profile['description'],
  24. 'img' => $profile['image'],
  25. 'weblog' => "$blog_home{$id}"
  26. ));
  27. $hobbies = split(", ", $profile['interests']);
  28. foreach ($hobbies as $hobby) {
  29. $writer->addInterest(array(
  30. 'title' => $hobby,
  31. 'uri' => "$tag_uri{$hobby}/"
  32. ));
  33. }
  34. foreach ($friends as $friend) {
  35. $writer->addKnow(array(
  36. 'nick' => $friend['name'],
  37. 'img' => $friend['logo'],
  38. 'seeAlso' => SCRIPT_PATH."?id={$friend['id']}",
  39. 'weblog' => $friend['link']
  40. ));
  41. }
  42. $writer->display();
  43. function array_e2u($array)
  44. {
  45. $result = array();
  46. foreach ($array as $key => $value) {
  47. if (is_array($value)) {
  48. $result[e2u($key)] = array_e2u($value);
  49. } else {
  50. $result[e2u($key)] = e2u($value);
  51. }
  52. }
  53. return $result;
  54. }
  55. function e2u($str)
  56. {
  57. return mb_convert_encoding($str, 'UTF-8', 'EUC-JP');
  58. }
  59. ?>