Guest User

Untitled

a guest
Oct 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. header('Content-type: text/html; charset=utf-8');
  2. user_Agent = 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0';
  3.  
  4. $id = $_POST["id"];
  5. // Übernahme Formulareingabe
  6. $url = "http://hub.culturegraph.org/entityfacts/118540238";
  7. // URL festlegen
  8.  
  9. $request_headers[] = 'Accept: application/json';
  10. $request_headers[] = 'charset=utf-8';
  11. $request_headers[] = 'Content-Type: application/json; charset=utf-8';
  12. $request_headers[] = 'Accept-Encoding: gzip, deflate, identity';
  13. $request_headers[] = 'Accept-Language: de,en-US;q=0.7,en;q=0.3';
  14. $request_headers[] = 'X-picturemaxx-api-key: key';
  15. $request_headers[] = "Authorization: Bearer token";
  16. $request_headers[] = 'Expect: ';
  17.  
  18. // Optionale Anfrageoptimierungen
  19.  
  20. $ch = curl_init($url);
  21. // Initiate curl
  22. curl_setopt($ch, CURLOPT_USERAGENT, $User_Agent);
  23. curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
  24. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  25. curl_setopt($ch, CURLOPT_ENCODING, "");
  26. // Anfrage optimieren
  27. // Execute
  28. $result = curl_exec($ch); // Performs the Request, with specified curl_setopt() options (if any).
  29. curl_close($ch);
  30. // Closing
  31.  
  32. $data = json_decode($result, true);
  33.  
  34. $url2 = "https://bpk.bs.picturemaxx.com/api/v1/editing/classifications/42/elements/2156190";
  35.  
  36. $alternativData = array();
  37. foreach($data['variantName'] as $alternativ) {
  38. echo $alternativ . " ; ";
  39. $alternativData[] = $alternativ;
  40. }
  41.  
  42.  
  43. $dataj = array (
  44. 'classification_element_parent_id' => 0,
  45. 'classification_element_matchcode' => '',
  46. 'classification_element_foreignref' => '',
  47. 'localized' =>
  48. array (
  49. 'en-us' =>
  50. array (
  51. 'classification_element_name' => '',
  52. ),
  53. 'de-de' =>
  54. array (
  55. 'classification_element_name' => substr(implode(' ; ', $alternativData),0 ,10000),
  56. ),
  57. ),
  58. );
  59.  
  60. $data_json = json_encode($dataj);
  61. $request_headers[] = 'Content-Length: ' . strlen($data_json);
  62.  
  63.  
  64. $ch2 = curl_init($url2);
  65. // Set the url
  66. curl_setopt( $ch2, CURLOPT_URL, $url2 );
  67. curl_setopt($ch2, CURLOPT_USERAGENT, $User_Agent);
  68. curl_setopt($ch2, CURLOPT_HTTPHEADER, $request_headers);
  69. curl_setopt($ch2, CURLOPT_ENCODING, "");
  70. curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
  71. curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'PUT');
  72. curl_setopt($ch2, CURLOPT_POSTFIELDS, $data_json);
  73.  
  74. // Execute
  75. $result2 = curl_exec($ch2); // Performs the Request, with specified curl_setopt() options (if any).
  76. $code = curl_getinfo($ch2, CURLINFO_HTTP_CODE);
  77. // Closing
  78. curl_close($ch2);
  79.  
  80. $url3 = "https://bpk.bs.picturemaxx.com/api/v1/editing/classifications/42/elements/2156191";
  81.  
  82. $birthdata = array();
  83. foreach($data['dateOfBirth'] as $birth) {
  84. echo $birth . " ; ";
  85. $birthData[] = $birth;
  86. }
  87.  
  88.  
  89. $dataj2 = array (
  90. 'classification_element_parent_id' => 2156190,
  91. 'classification_element_matchcode' => '',
  92. 'localized' =>
  93. array (
  94. 'en-us' =>
  95. array (
  96. 'classification_element_name' => '',
  97. ),
  98. 'de-de' =>
  99. array (
  100. 'classification_element_name' => $data['dateOfBirth'],
  101. ),
  102. ),
  103. );
  104.  
  105. $data_json2 = json_encode($dataj2);
  106. $request_headers[] = 'Content-Length: ' . strlen($data_json2);
  107.  
  108. $ch3 = curl_init($url3);
  109. // Set the url
  110. curl_setopt( $ch3, CURLOPT_URL, $url3 );
  111. curl_setopt($ch3, CURLOPT_USERAGENT, $User_Agent);
  112. curl_setopt($ch3, CURLOPT_HTTPHEADER, $request_headers);
  113. curl_setopt($ch3, CURLOPT_ENCODING, "");
  114. curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true);
  115. curl_setopt($ch3, CURLOPT_CUSTOMREQUEST, 'PUT');
  116. curl_setopt($ch3, CURLOPT_POSTFIELDS, $data_json2);
  117.  
  118. // Execute
  119. $result3 = curl_exec($ch3); // Performs the Request, with specified curl_setopt() options (if any).
  120. $code = curl_getinfo($ch3, CURLINFO_HTTP_CODE);
  121. // Closing
  122. curl_close($ch3);
Add Comment
Please, Sign In to add comment