コード例 #1
0
ファイル: MyCurl.php プロジェクト: Terradex/sugar
 function post_edit($url, $post_data, $arr_headers = array(), &$http_code, $evid, $tablename, $_entry, $old_link_edit, $user_data)
 {
     //$auth=getAuthCode($user_data[0],$user_data[1]);     // 190509 not working if not ssl on server
     $this->login();
     $auth = $this->fAuth;
     $header = array();
     $header[] = "MIME-Version: 1.0";
     $header[] = "Accept: text/xml";
     $header[] = "Authorization: GoogleLogin auth=" . $auth;
     $header[] = "Content-length: " . strlen($_entry);
     $header[] = "Content-type: application/atom+xml";
     $header[] = "Cache-Control: no-cache";
     $header[] = "Connection: close \r\n";
     $header[] = $_entry;
     $link = $old_link_edit;
     $entry1 = curlToHost($link, 'PUT', $header);
     $entry = $entry1;
     $checkok = explode("<link rel='edit' type='application/atom+xml' href='", $entry);
     $checkok1 = explode("'/>", $checkok[1]);
     $checkok_url = $checkok1[0];
     if ($checkok_url != '') {
         if ($tablename == "tasks") {
             $mmod = new Task();
             $mmod1 = new Task();
         }
         if ($tablename == "meetings") {
             $mmod = new Meeting();
             $mmod1 = new Meeting();
         }
         if ($tablename == "calls") {
             $mmod = new Call();
             $mmod1 = new Call();
         }
         $newtbname = $tablename . "_cstm";
         $cs1 = "delete from {$newtbname} where id_c='{$evid}'";
         $cs2 = "insert into {$newtbname} (id_c,google_response_c) values ('{$evid}',\"{$entry}\")";
         debugg("<br>update ev1 >" . $cs1);
         debugg("<br>update ev1 >" . $cs2);
         $r = $mmod->db->query($cs1);
         $r = $mmod->db->query($cs2);
         $s1 = explode("<entry xmlns", $entry);
         $s2 = explode("</entry>", $s1[1]);
         $xmlstr = "<entry xmlns" . $s2[0] . "</entry>";
         $xmlparse =& new ParseXML();
         $xml = $xmlparse->GetXMLTree($xmlstr);
         $old_id = $xml['ENTRY'][0]['ID'][0]['VALUE'];
         $old_published = $xml['ENTRY'][0]['PUBLISHED'][0]['VALUE'];
         $old_updated = $xml['ENTRY'][0]['UPDATED'][0]['VALUE'];
         $old_link_alt = $xml['ENTRY'][0]['LINK'][0]['ATTRIBUTES']['HREF'];
         $old_link_self = $xml['ENTRY'][0]['LINK'][1]['ATTRIBUTES']['HREF'];
         $old_link_edit = $xml['ENTRY'][0]['LINK'][2]['ATTRIBUTES']['HREF'];
         $old_author = $xml['ENTRY'][0]['AUTHOR'][0]['NAME'][0]['VALUE'];
         $old_email = $xml['ENTRY'][0]['AUTHOR'][0]['EMAIL'][0]['VALUE'];
         $mmod1->retrieve($evid);
         $mmod1->old_id_c = $old_id;
         $mmod1->old_published_c = $old_published;
         $mmod1->old_updated_c = $old_updated;
         $mmod1->old_link_alt_c = $old_link_alt;
         $mmod1->old_link_self_c = $old_link_self;
         $mmod1->old_link_edit_c = $old_link_edit;
         $mmod1->old_author_c = $old_author;
         $mmod1->old_email_c = $old_email;
         $mmod1->Save();
         debugg("<br>***** Event update ok");
     } else {
         debugg("<br>***** Error updating event .. response " . print_r($entry));
     }
 }