mysql - How to delete video from Vimeo account through vimeo api -
in previous asked question how upload video in vimeo account through vimeo api in symfony 2.2 closed . have 1 more requirement want delete uploaded video vimeo account through application of vimeo api used
"vimeo.videos.delete" method given below
/** * deletes 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 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 api error -- code {$e->getcode()} - {$e->getmessage()}"; } } return $this->redirect($this->generateurl('video')); } }
but when try delete selected video in application , try delete video can't delete video vimeo account while database references infos of video deleted while want delete video both database , vimeo account . do't konow wrong m doing ?
if regarding issue available , please me resolve issue .
now little bit change in coding have solved !
/** * deletes 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 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 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; }
Comments
Post a Comment