API: How do I change release dates?

PepiMK

New member
Again, based on the unfinished documentation, I tried to write code to fix broken release dates.

What am I doing wrong, which endpoint do I need to use to change a resource version?

PHP:
    protected function update_xenforo_resource_version_date(string $version_id, string $resource_id, int $newdate, string $download_url): mixed
    {
        $aHeaders = ['Content-Type: application/x-www-form-urlencoded', 'XF-Api-Key: ' . $this->XenForoAPIKey];
        $aFields = array(
            'resource_id' => $resource_id,
            'resource_version_id' => $version_id,
            'release_date' => $newdate,
            'external_download_url' => $download_url,
        );
        $ch = curl_init();
        /**
         * api/resource-versions/{$resource_id}/ - invalid endpoint, only GET and DELETE allowed
         * api/resources/{$resource_id}/versions/{$version_id}/ - invalid route
         * api/resource-versions/ - creates a new version instead, even though resource_version_id is specified
         * api/resources/{$resource_id}/ - returns resource, does not update version
         */
        curl_setopt($ch, CURLOPT_URL, $this->XenForoURL . "api/resources/{$resource_id}/");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($aFields));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeaders);
        $output = curl_exec($ch);
        curl_close($ch);      
        return json_decode($output);
    }
 
Back
Top Bottom