<?php

namespace Blazemedia\Affiliation\API;

class Proxy extends ApiGET {

    protected string $action     = 'proxy';
    protected array  $parameters = ['url'];
    
    protected function transientKey() {
        
        $this->params->url = str_replace(['https:/', 'https:///' ], 'https://', $this->params->url );    

        return "proxy_{$this->params->url}";
    }


    protected function getData(){

        header('Content-Type: application/json; charset=utf-8');

        $this->params->url = str_replace(['https:/', 'https:///' ], 'https://', $this->params->url );

        $result = file_get_contents ( $this->params->url , false, stream_context_create([
                
                "ssl" => [
                    "verify_peer"=>false, "verify_peer_name"=>false,
                ]
            ])
        );

        return $result;
    }

}