From 29e3563555f14b118dcc1505c7ddae4b388fc6af Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Tue, 27 Dec 2022 22:55:11 -0500 Subject: [PATCH] get pins --- Plex.php | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 11 +++++++++ 2 files changed, 80 insertions(+) create mode 100644 Plex.php create mode 100644 index.php diff --git a/Plex.php b/Plex.php new file mode 100644 index 0000000..ff07141 --- /dev/null +++ b/Plex.php @@ -0,0 +1,69 @@ +clientID = $clientName; + $this->plexProduct = $productName; + } + + private function getPins() { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, "https://plex.tv/api/v2/pins"); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + $headers = array("Content-Type: application/x-www-form-urlencoded", "accept: application/json"); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + $data = "strong=true&X-Plex-Product=" . $this->plexProduct . "&X-Plex-Client-Identifier=" . $this->clientID; + + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + + $resp = curl_exec($curl); + + $returnCode = curl_getinfo($curl, CURLINFO_RESPONSE_CODE); + + curl_close($curl); + + if($returnCode != 201) + return false; + + return $resp; + } + + public function getURL(){ + + $pinJSON = $this->getPins(); + if(!$pinJSON){ + return false; + } + + $parsedPinJSON = json_decode($pinJSON,true); + $this->id = parsedPinJSON["id"]; + $this->code = parsedPinJSON["code"]; + } + + + +} + + + + +?> diff --git a/index.php b/index.php new file mode 100644 index 0000000..7fb9d75 --- /dev/null +++ b/index.php @@ -0,0 +1,11 @@ + +getURL()); + + +?>