Advertisement
Guest User

Untitled

a guest
Jan 29th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.93 KB | None | 0 0
  1. $array = array();
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_URL, 'http://shikimori.org/api/animes/31637');
  4. curl_setopt($ch, CURLOPT_HEADER, false);
  5. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6. curl_setopt($ch, CURLOPT_USERAGENT, "User Agent");
  7. if ($content = curl_exec($ch)) {
  8. $array = json_decode($content, true);
  9. }
  10. curl_close($ch);
  11.  
  12. echo '<pre>';
  13. print_r($array);
  14.  
  15. Array
  16. (
  17. [id] => 31637
  18. [name] => Gate: Jieitai Kanochi nite, Kaku Tatakaeri 2nd Season
  19. [russian] => Врата: Там бьются наши воины — Огнедышащие драконы
  20. [image] => Array
  21. (
  22. [original] => /images/anime/original/31637.jpg?1453660380
  23. [preview] => /images/anime/preview/31637.jpg?1453660380
  24. [x96] => /images/anime/x96/31637.jpg?1453660380
  25. [x48] => /images/anime/x48/31637.jpg?1453660380
  26. )
  27.  
  28. [url] => /animes/31637-gate-jieitai-kanochi-nite-kaku-tatakaeri-2nd-season
  29. [kind] => tv
  30. [ongoing] => 1
  31. [anons] =>
  32. [status] => ongoing
  33. [episodes] => 12
  34. [episodes_aired] => 4
  35. [rating] => r
  36. [english] => Array
  37. (
  38. )
  39.  
  40. [japanese] => Array
  41. (
  42. [0] => GATE(ゲート)自衛隊 彼の地にて、斯く戦えり 第2クール
  43. )
  44.  
  45. [synonyms] => Array
  46. (
  47. [0] => Gate: Thus the JSDF Fought There! Fire Dragon Arc
  48. [1] => Gate: Jieitai Kanochi nite
  49. [2] => Kaku Tatakaeri - Enryuu-hen
  50. [3] => Gate Jieitai Kanochi Nite Kaku Tatakaeri 2nd Season
  51. )
  52.  
  53. [aired_on] => 2016-01-09
  54. [released_on] => 2016-03-26
  55. [duration] => 23
  56. [score] => 8.17
  57. [description] => Second season of the [i]Gate[/i] anime. Adapts Enryuu-hen, and Douran-hen arcs.
  58. [description_html] => Second season of the Gate anime. Adapts Enryuu-hen, and Douran-hen arcs.
  59. [favoured] =>
  60. [thread_id] => 184926
  61. [world_art_id] => 0
  62. [myanimelist_id] => 31637
  63. [ani_db_id] => 0
  64. [rates_scores_stats] => Array
  65. (
  66. [0] => Array
  67. (
  68. [name] => 10
  69. [value] => 231
  70. )
  71.  
  72. [1] => Array
  73. (
  74. [name] => 9
  75. [value] => 99
  76. )
  77.  
  78. [2] => Array
  79. (
  80. [name] => 8
  81. [value] => 84
  82. )
  83.  
  84. [3] => Array
  85. (
  86. [name] => 7
  87. [value] => 35
  88. )
  89.  
  90. [4] => Array
  91. (
  92. [name] => 6
  93. [value] => 15
  94. )
  95.  
  96. [5] => Array
  97. (
  98. [name] => 5
  99. [value] => 3
  100. )
  101.  
  102. [6] => Array
  103. (
  104. [name] => 3
  105. [value] => 1
  106. )
  107.  
  108. [7] => Array
  109. (
  110. [name] => 1
  111. [value] => 1
  112. )
  113.  
  114. )
  115.  
  116. [rates_statuses_stats] => Array
  117. (
  118. [0] => Array
  119. (
  120. [name] => Запланировано
  121. [value] => 2303
  122. )
  123.  
  124. [1] => Array
  125. (
  126. [name] => Смотрю
  127. [value] => 2023
  128. )
  129.  
  130. [2] => Array
  131. (
  132. [name] => Просмотрено
  133. [value] => 34
  134. )
  135.  
  136. [3] => Array
  137. (
  138. [name] => Отложено
  139. [value] => 52
  140. )
  141.  
  142. [4] => Array
  143. (
  144. [name] => Брошено
  145. [value] => 7
  146. )
  147.  
  148. )
  149.  
  150. [genres] => Array
  151. (
  152. [0] => Array
  153. (
  154. [id] => 2
  155. [name] => Adventure
  156. [russian] => Приключения
  157. [kind] => anime
  158. )
  159.  
  160. [1] => Array
  161. (
  162. [id] => 1
  163. [name] => Action
  164. [russian] => Экшен
  165. [kind] => anime
  166. )
  167.  
  168. [2] => Array
  169. (
  170. [id] => 38
  171. [name] => Military
  172. [russian] => Военное
  173. [kind] => anime
  174. )
  175.  
  176. [3] => Array
  177. (
  178. [id] => 10
  179. [name] => Fantasy
  180. [russian] => Фэнтези
  181. [kind] => anime
  182. )
  183.  
  184. )
  185.  
  186. [studios] => Array
  187. (
  188. [0] => Array
  189. (
  190. [id] => 56
  191. [name] => A-1 Pictures Inc.
  192. [filtered_name] => A-1 Pictures Inc.
  193. [real] => 1
  194. [image] => /images/studio/original/56.?1434707196
  195. )
  196.  
  197. )
  198.  
  199. [videos] => Array
  200. (
  201. [0] => Array
  202. (
  203. [id] => 11435
  204. [url] => http://youtu.be/oPfeTTcZGhs
  205. [image_url] => http://shikimori.org/images/31637
  206. [player_url] => http://youtube.com/embed/oPfeTTcZGhs
  207. [name] =>
  208. [kind] => PV
  209. [hosting] => youtube
  210. )
  211.  
  212. [1] => Array
  213. (
  214. [id] => 12579
  215. [url] => http://youtu.be/TrwXsOTWUeU
  216. [image_url] => http://shikimori.org/images/31637
  217. [player_url] => http://youtube.com/embed/TrwXsOTWUeU
  218. [name] =>
  219. [kind] => PV
  220. [hosting] => youtube
  221. )
  222.  
  223. )
  224.  
  225. [screenshots] => Array
  226. (
  227. )
  228.  
  229. [user_rate] =>
  230. )
  231.  
  232. $name=($array["name"]);
  233. $russian=($array["russian"]);
  234. $kind=($array["kind"]);
  235. $status=($array["status"]);
  236. $episodes=($array["episodes"]);
  237. $episodes_aired=($array["episodes_aired"]);;
  238. $aired_on=($array["aired_on"]);
  239. $released_on=($array["released_on"]);
  240. $duration=($array["duration"]);
  241. $description=($array["description"]);
  242.  
  243. $servername = "localhost";
  244. $username = "root";
  245. $password = "";
  246. $dbname = "Animebase";
  247.  
  248. // Create connection
  249. $conn = new mysqli($servername, $username, $password, $dbname);
  250. // Check connection
  251. if ($conn->connect_error) {
  252. die("Connection failed: " . $conn->connect_error);
  253. }
  254.  
  255. $sql = "INSERT INTO anime (name , russian , kind , status, episodes, episodes_aired, aired_on, released_on, duration, description ) VALUES('$name' , '$russian' , '$kind' , '$status', '$episodes', '$episodes_aired', '$aired_on', '$released_on', '$duration', '$description' )"or die("Ошибка…");
  256. if ($conn->query($sql) === TRUE) {
  257. echo "New record created successfully";
  258. } else {
  259. echo "Error: " . $sql . "<br>" . $conn->error;
  260. }
  261.  
  262. $conn->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement