2011-04-20 8 views
1

Google 문서 도구 및 Zend Framework 1.11.4에서 작업하는 데 문제가 있습니다.Zend Gdata를 사용하여 Google 문서 도구에서 문서 삭제

내가하려는 것은 Google 문서 도구에 문서를 업로드하고 HTML 콘텐츠를 검색하고 문서를 삭제하는 것입니다. 나는 .doc, .pdf 및 .rtf 파일을 가지고 일하고있다. 지금까지

내 코드 :

$client = Zend_Gdata_ClientLogin::getHttpClient(
    '[email protected]', 
    'MyPassword', 
    Zend_Gdata_Docs::AUTH_SERVICE_NAME 
); 
$gdClient = new Zend_Gdata_Docs($client); 

$newDocumentEntry = $gdClient->uploadFile(
    $file, 
    null, 
    null, 
    Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI 
); 

$cv = file_get_contents($newDocumentEntry->getContent()->getSrc()); 

$newDocumentEntry->delete(); 

모든 것이 잘 작동 할 때까지 -> 삭제() 메소드가있어,이 예외 예상 응답 코드 (200)를 반환라고 409

내가왔다 Googles 문서에 따르면 문서를 삭제하는 올바른 방법은 며칠 동안 Google 검색 결과를 찾을 수 있지만 답변을 찾을 수 없습니다.

누군가 내가 뭘 잘못하고 있는지에 대한 아이디어가 있다면 어떤 도움도 매우 환영받을 것입니다. 사전에

많은 감사, 게리 Zend_Gdata_Calendar 라이브러리를 사용할 때이 같은 409 응답 문제가 발생했다

+0

409 CONFLICT - 지정된 버전 번호가 자원의 최신 버전 번호와 일치하지 않습니다. 문서를 "다시 가져와야"한다고 생각하십시오 (ID로 검색 ..) – opHASnoNAME

+0

감사합니다 ArneRie, 나는 그것을 시도 할 것입니다. – Garry

+1

@ArneRie 아직 답을 찾을 수 없을 때까지 계획 B에 의지 할 것입니다. [ZendCast] (http://www.zendcasts.com/forum/topic/345/zendgdata-google-docs/)에서이 주제에 대한 화면 캐스트를 요청했습니다. – Garry

답변

0

. Zend 프레임 워크 버그 래커에 공개 버그가 있습니다. http://zendframework.com/issues/browse/ZF-10194

Gdata_App 클래스 또는 체인의 하위 클래스 중 하나에서 "If-Match"헤더가 설정되지 않은 것 같습니다. 그런 다음 그것을 사용

class Zend_Gdata_Calendar_Fixed extends \Zend_Gdata_Calendar { 
    /** 
    * Overridden to fix an issue with the HTTP request/response for deleting. 
    * @link http://zendframework.com/issues/browse/ZF-10194 
    */ 
    public function prepareRequest($method, 
            $url = null, 
            $headers = array(), 
            $data = null, 
            $contentTypeOverride = null) { 
     $request = parent::prepareRequest($method, $url, $headers, $data, $contentTypeOverride); 

     if($request['method'] == 'DELETE') { 
      // Default to any 
      $request['headers']['If-Match'] = '*'; 

      if($data instanceof \Zend_Gdata_App_MediaSource) { 
       $rawData = $data->encode(); 
       if(isset($rawData->etag) && $rawData->etag != '') { 
        // Set specific match 
        $request['headers']['If-Match'] = $rawData->etag; 
       } 
      } 
     } 
     return $request; 
    } 
} 

:

... 
$gdata = new Zend_Gdata_Calendar_Fixed($httpClient); 
... 

을 당신이 할 수있는 상상

내가 Zend_Gdata_Calendar 클래스를 오버라이드 (override)과 하나 대신 내 클래스를 인스턴스화 한 달력 API 위해 그것을 해결하려면 같은 일을하지만 Zend_Gdata_Docs 클래스를 오버라이드합니다.

관련 문제