Index: trunk/extensions/YouTubeAuthSub/YouTubeAuthSub_body.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | function execute( $par ) { |
19 | 19 | global $wgRequest, $wgTitle, $wgOut, $wgMemc, $wgUser; |
20 | 20 | global $wgYTAS_User, $wgYTAS_Password, $wgYTAS_DeveloperId; |
21 | | - global $wgYTAS_DefaultCategory, $wgYTAS_UseClientLogin, $wgYTAS_EnableLogging, $wgYTAS_UseNamespace; |
| 21 | + global $wgYTAS_DefaultCategory, $wgYTAS_UseClientLogin, $wgYTAS_EnableLogging, $wgYTAS_UseNamespace, $wgYTAS_ClientId; |
22 | 22 | |
23 | 23 | wfLoadExtensionMessages( 'YouTubeAuthSub' ); |
24 | 24 | |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | |
125 | 125 | if ($wgRequest->wasPosted()) { |
126 | 126 | $url = "http://uploads.gdata.youtube.com/feeds/api/users/{$wgYTAS_User}/uploads"; |
127 | | - |
| 127 | + $url = "http://gdata.youtube.com/action/GetUploadToken"; |
128 | 128 | $data = "<?xml version='1.0'?> |
129 | 129 | <entry xmlns='http://www.w3.org/2005/Atom' |
130 | 130 | xmlns:media='http://search.yahoo.com/mrss/' |
— | — | @@ -138,6 +138,8 @@ |
139 | 139 | </entry> |
140 | 140 | "; |
141 | 141 | $headers = array ( |
| 142 | + "GData-Version: 2", |
| 143 | + "X-GData-Client: key={$wgYTAS_ClientId}", |
142 | 144 | "X-GData-Key: key={$wgYTAS_DeveloperId}", |
143 | 145 | "Content-Type: application/atom+xml; charset=UTF-8", |
144 | 146 | "Content-Length: " . strlen($data), |
— | — | @@ -149,10 +151,8 @@ |
150 | 152 | |
151 | 153 | $results = wfSpecialYouTubePost($url, $data, $headers); |
152 | 154 | |
153 | | - preg_match("/<yt:token>.*<\/yt:token>/", $results, $matches); |
154 | | - $token = strip_tags($matches[0]); |
155 | | - preg_match("/'edit-media'[^>]*href='[^']*'>/", $results, $matches); |
156 | | - $url = preg_replace("/.*href='([^']*)'>/", "$1", $matches[0]); |
| 155 | + $url = preg_replace("@.*<url>(.*)</url>.*@", "$1", $results); |
| 156 | + $token = preg_replace("@.*<token>(.*)</token>.*@", "$1", $results); |
157 | 157 | |
158 | 158 | if ($url == "") { |
159 | 159 | $wgOut->addHTML("Unable to extract URL, results where <pre>{$results}</pre>"); |