Changeset 45990 in spip-zone
- Timestamp:
- Mar 27, 2011, 1:45:08 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/seenthis/inc/seenthis.php
r45988 r45990 54 54 55 55 56 function create_xml($message, $id_me=0, $inreplyto=0) { 56 function create_xml($message, $id=null, $inreplyto=null) { 57 57 58 $xml = "<?xml version='1.0' encoding='UTF-8'?>\n" 58 59 ."<entry xmlns='http://www.w3.org/2005/Atom' xmlns:thr='http://purl.org/syndication/thread/1.0'>\n"; 59 if ($id_me) $xml .= "<id>$id_me</id>\n"; 60 61 if ($id = $this->numeric($id)) 62 $xml .= "<id>message:$id</id>\n"; 63 60 64 $xml .= "<summary><![CDATA[".trim($message)."]]></summary>\n"; 61 if ($inreplyto) $xml .= "<thr:in-reply-to ref='$inreplyto'/>\n"; 65 66 if ($inreplyto = $this->numeric($inreplyto)) 67 $xml .= "<thr:in-reply-to ref='message:$inreplyto'/>\n"; 68 62 69 $xml .= "</entry>\n"; 63 70 … … 75 82 curl_setopt($request, CURLOPT_USERPWD, $this->login.':'.$this->pass); 76 83 curl_setopt($request, CURLOPT_POSTFIELDS, "$xml"); 77 84 78 85 $post_response = curl_exec($request); // execute curl post and store results in $post_response 79 86 curl_close ($request); // close curl object … … 96 103 } 97 104 98 function post($message, $inreplyto=0) { 99 $xml = $this->create_xml($message, 0, $inreplyto) ; 105 function read($id = null) { 106 // si on ne précise pas le message, c'est le plus récent de notre feed 107 // sinon c'est le message demandé 108 if (is_null($id)) { 109 $a = $this->feed(); 110 if (!$a->error) { 111 $b = $a->entry[0]; 112 $b->xml = (string) $a->xml; 113 return $b; 114 } 115 else 116 return $a; 117 } 118 119 else 120 return $this->curl("", 'GET', 'messages/'.$this->numeric($id)); 121 } 122 123 function post($message, $inreplyto=null) { 124 $xml = $this->create_xml($message, null, $inreplyto) ; 100 125 return $this->curl($xml, 'POST', 'messages'); 101 126 } 102 127 103 function update($message, $ me) {104 $xml = $this->create_xml($message, $ me);128 function update($message, $id) { 129 $xml = $this->create_xml($message, $id); 105 130 return $this->curl($xml, 'PUT', 'messages'); 106 131 } … … 109 134 if (!strlen($login)) 110 135 $login = $this->login; 111 return $this->curl("", 'GET', 'people/'. $login.'/messages/'.$nb);136 return $this->curl("", 'GET', 'people/'.rawurlencode($login).'/messages/'.$nb); 112 137 } 113 138 139 140 // supprimer le 'message:' d'un id 141 private function numeric($id) { 142 if ($id = intval(preg_replace('/^message:/', '', $id))) 143 return $id; 144 } 114 145 115 146 } // class Seenthis
Note: See TracChangeset
for help on using the changeset viewer.