service/modules/api/v1/controllers/ContentProviderController.php
/**
     * Checks if content provider is "alive"
     *
     * Checks if content provider is able to download content.
     * Link (and password) to file may be provided as action params.
     * If link is not provided it will be taken from curently existing links.
     *
     * Method: GET
     *
     * Call example: http://svc.plg.com/api/content-providers/is-alive/1
     *
     * Example of response:
     * ```json
     * {
     *  "isAlive": "yes",
     *  "provider": {
     *   "id": 2,
     *   "name": "1fichier.com",
     *   "class": "service\\components\\contents\\OneFichierCom",
     *   "urlTpl": "https?:\\/\\/1fichier\\.com\\/.+",
     *   "authUrl": "https://1fichier.com/login.pl",
     *   "downloadable": 1,
     *   "streamable": 0,
     *   "storable": 1,
     *   "useProxy": 0,
     *   "status": "ACTIVE",
     *   "created": 1477909318,
     *   "updated": null
     *  },
     *  "link": {
     *   "id": 5,
     *   "userId": 14,
     *   "link": "https://1fichier.com/?camvve48y9",
     *   "password": null,
     *   "downloadLink": "http://svc.plg.com/content/download/e0ddc8cd96a6b8fb6e830e9c992d6ade2ae48884",
     *   "streamLink": null,
     *   "contentName": "video_file_sm.mp4",
     *   "contentSize": 5253880,
     *   "created": 1478526737
     *  },
     *  "content": {
     *   "length": 5253880,
     *   "name": "video_file_sm.mp4",
     *   "mimeType": "video/mp4"
     *  }
     * }
     *
     * @param  integer $id
     * @param  string $link
     * @param  string $password
     * @return mixed
     * @api
     */
Checks if content provider is "alive"
Checks if content provider is able to download content.
Link (and password) to file may be provided as action params.
If link is not provided it will be taken from curently existing links.

GET






Checks if content provider is " alive " Checks if content provider is able to download content . Link ( and password ) to file may be provided as action params . If link is not provided it will be taken from curently existing links . GET
public function actionIsAlive($id, $link = null, $password = null)
    {
        $response = Yii::$app->response;
        $provider = ContentProvider::findOne($id);
        if ($provider === null) {
            $response->setStatusCode(404);
            return [
                'message' => 'Content provider not found.'
            ];
        }
        if ($link != null) {
            $lnk = new Link();
            $lnk->link = $link;
            if ($password) {
                $lnk->password = $password;
            }
        } else {
            $lnk = Link::find()
                ->where(['REGEXP', 'link', $provider->url_tpl])
                ->orderBy(['created' => SORT_DESC])
                ->one();
        }
        if ($lnk === null) {
            $response->setStatusCode(404);
            return [
                'message' => 'Link not found.'
            ];
        }
        try {
            $content = $provider->getContent($lnk);
            return [
                'isAlive' => 'yes',
                'provider' => $provider,
                'link' => $lnk,
                'content' => $content
            ];
        } catch (\Exception $e) {
            return [
                'isAlive' => 'no',
                'provider' => $provider,
                'link' => $lnk,
                'message' => $e->getMessage()
            ];
        }
    }
public function actionIsAlive ( $ id , $ link = null , $ password = null ) { $ response = Yii :: $ app -> response ; $ provider = ContentProvider :: findOne ( $ id ) ; if ( $ provider === null ) { $ response -> setStatusCode ( 404 ) ; return [ 'message' => 'Content provider not found.' ] ; } if ( $ link != null ) { $ lnk = new Link ( ) ; $ lnk -> link = $ link ; if ( $ password ) { $ lnk -> password = $ password ; } } else { $ lnk = Link :: find ( ) -> where ( [ 'REGEXP' , 'link' , $ provider -> url_tpl ] ) -> orderBy ( [ 'created' => SORT_DESC ] ) -> one ( ) ; } if ( $ lnk === null ) { $ response -> setStatusCode ( 404 ) ; return [ 'message' => 'Link not found.' ] ; } try { $ content = $ provider -> getContent ( $ lnk ) ; return [ 'isAlive' => 'yes' , 'provider' => $ provider , 'link' => $ lnk , 'content' => $ content ] ; } catch ( \ Exception $ e ) { return [ 'isAlive' => 'no' , 'provider' => $ provider , 'link' => $ lnk , 'message' => $ e -> getMessage ( ) ] ; } }
Checks if content provider is "alive"
 Checks if content provider is able to download content.
Checks if content provider is " alive " Checks if content provider is able to download content .