api.php 1017 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. $config = require "config.php";
  3. require "example/path.php";
  4. if (!isset($_REQUEST["q"]))
  5. {
  6. echo "<p>Example API request: ./api.php?q=pinternet";
  7. die();
  8. }
  9. $query = $_REQUEST["q"];
  10. // Pinterest API Endpoint
  11. $api_url = "https://api.pinterest.com/v1/boards/{board_id}/pins/";
  12. // Replace {board_id} with the actual board ID
  13. $board_id = "replace_with_actual_board_id";
  14. // Replace {access_token} with a valid Pinterest access token
  15. $access_token = "replace_with_actual_access_token";
  16. // Create the API request URL
  17. $request_url = $api_url . "?access_token=" . $access_token;
  18. // Send a GET request to the Pinterest API
  19. $response = file_get_contents($request_url);
  20. // Decode the JSON response into a PHP array
  21. $pins = json_decode($response, true);
  22. // Loop through the pins and display each one
  23. foreach ($pins["data"] as $pin) {
  24. echo '<div>';
  25. echo '<img src="' . $pin["image"]["original"]["url"] . '" alt="' . $pin["description"] . '">';
  26. echo '<p>' . $pin["description"] . '</p>';
  27. echo '</div>';
  28. }
  29. ?>