2012-07-17 4 views
0

누구든지 php cURL을 사용하여 Google 캘린더에서 일정을 삭제하는 방법을 알고 있습니까? eventid를 얻는 방법과 삭제하는 방법에 대한 예제가 필요합니다. 나는 약간 연구를하고 "CURLOPT_CUSTOMREQUEST"로 그것을하는 방법이 나왔다 그러나 어떤보기를 찾아 낼 수 없었다 ...cURL을 사용하여 Google 캘린더에서 일정을 삭제하는 방법

+0

당신은 무엇을 시도 했습니까? API가 있습니까? –

+0

어디에서 찾았습니까? [this] (https://developers.google.com/google-apps/calendar/v3/reference/events) 및 [this] (http://code.google.com/p/google-api-php) -client/source/browse/trunk/examples/calendar/simple.php)를 Google 캘린더 API에서 가져옵니다. – Jasonw

+0

Google은 캘린더를 비롯한 다양한 서비스와 상호 작용할 수있는 PHP 클라이언트 측 라이브러리를 제공합니다. http://code.google.com/p/google-api-php-client/ 클라이언트 라이브러리를 사용하여 캘린더 항목을 학습하는 방법을 보여주는 간단한 예가 있습니다. – Cheeso

답변

0
$calendarId ="[email protected]"; 
    $eventId = 'XXXXXXXXXXXXXXXXXXXXX'; 


    $APIKEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';  

    $tokenURL = 'https://accounts.google.com/o/oauth2/token'; 
    $postData = array(
     'client_secret'=>'XXXXXXXXXXXXXXXXX', 
     'grant_type'=>'refresh_token', 
     'refresh_token'=>'1/XXXXXXXXXXXXXXXXXXXXXXXX', 
     'client_id'=>'XXXXXXXXXXXXXXXXX.apps.googleusercontent.com' 
    ); 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $tokenURL); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    $tokenReturn = curl_exec($ch); 
    $token = json_decode($tokenReturn); 
    //var_dump($tokenReturn); 
    $accessToken = $token->access_token; 

    //$token = getAccessToken(); 
    //echo $token; exit; 

    //var_dump($auth); 
    $request = 'https://www.googleapis.com/calendar/v3/calendars/' . $calendarId . '/events/'.$eventId.'?sendNotifications=true&key=' . $APIKEY; 

    $ch = curl_init($request); 
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: Bearer '. $accessToken) 
    ); 
    $response = curl_exec($ch); 
    $httpCode = curl_getinfo($response, CURLINFO_HTTP_CODE); 

    $result = json_decode($response); 
+0

안녕하세요. 코드에 설명을 추가하는 것을 고려하십시오. –

관련 문제