0

私の以前の質問で、Symfony 2.2 で vimeo api を介して vimeo アカウントにビデオをアップロードする方法 は現在閉鎖されています。今、私が使用したvimeo apiの助けを借りて、アプリケーションを介してvimeoアカウントからアップロードされたビデオを削除したいというもう1つの要件があります。

以下の「vimeo.videos.delete」メソッド

/**
 * Deletes a Video entity.
 *
 * @Route("/{id}", name="video_delete")
 * @Method("DELETE")
 * @Secure(roles="ROLE_SUPER_ADMIN")
 */
public function deleteAction(Request $request, $id)
{
    $vimeo = new phpVimeo('my_api_key', 'my_api_key_secret', 'my_token', 'my_token_secret');
    $form = $this->createDeleteForm($id);
    $form->bind($request);
    $em = $this->getDoctrine()->getManager();
    $video = $em->getRepository('MyBundle:Video')->find($id);

        if (!$video) {
            throw $this->createNotFoundException('Unable to find Video entity.');
        }
    $videoId = $video->getVideoId();

    if ($form->isValid()) {
        try
        {
        $vimeo->call('vimeo.videos.delete',array('video_id',$videoId));
        $em->remove($video);
        $em->flush();
    }
    catch (VimeoAPIException $e) {
            echo "Encountered an API error -- code {$e->getCode()} - {$e->getMessage()}";
        }
    }

    return $this->redirect($this->generateUrl('video'));
    }
}

しかし、アプリケーションで選択したビデオを削除しようとすると、ビデオを削除しようとしますが、両方からビデオを削除したいときに、データベース参照情報からこのビデオの情報が削除されている間に、vimeo アカウントからビデオを削除できません。データベースとvimeoアカウント。私は何が間違っているのかわかりませんか?

この問題に関するヘルプがあれば、この問題の解決を手伝ってください。

4

1 に答える 1

0

今、私のコーディングを少し変更することで、私はそれを解決しました!

/**
 * Deletes a Video entity.
 *
 * @Route("/{id}", name="video_delete")
 * @Method("DELETE")
 * @Secure(roles="ROLE_SUPER_ADMIN")
 */
public function deleteAction(Request $request, $id)
{
    $form = $this->createDeleteForm($id);
    $form->bind($request);
    $em = $this->getDoctrine()->getManager();
    $video = $em->getRepository('MyBundle:Video')->find($id);

        if (!$video) {
            throw $this->createNotFoundException('Unable to find Video entity.');
        }
    $videoId = $entity->getVideoId();

    if ($form->isValid()) {
        try
        {
        $api = $this->api();

        $method = 'vimeo.videos.delete';

        $query = array();
        $query['video_id'] = $videoId;

        $r = $api->call($method, $query);

    }
    catch (VimeoAPIException $e) {
            echo "Encountered an API error -- code {$e->getCode()} - {$e->getMessage()}";
        }
        $em->remove($video);
        $em->flush();
    }

    return $this->redirect($this->generateUrl('video',array('result'=> $r)));
    }

 public function api()
{
    $consumer_key = 'my_api_key';
    $consumer_secret = 'my_api_key_secret';

    $token = 'my_access_token';
    $token_secret = 'my_access_token_secret';

    $vimeo = new phpVimeo($consumer_key, $consumer_secret);
    $vimeo->setToken($token, $token_secret);

    return $vimeo;
}
于 2013-06-13T10:57:29.813 に答える