Changeset View
Changeset View
Standalone View
Standalone View
src/ParsoidClient.php
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | class ParsoidClient { | ||||
} | } | ||||
/** | /** | ||||
* @param string $text | * @param string $text | ||||
* @return string|bool False on failure, html otherwise | * @return string|bool False on failure, html otherwise | ||||
*/ | */ | ||||
protected function fetchParse( $text ) { | protected function fetchParse( $text ) { | ||||
$parms = array( | $parms = array( | ||||
'wt' => $text, | 'wikitext' => $text, | ||||
'body' => 1, | 'body_only' => 1, | ||||
); | ); | ||||
$ch = curl_init(); | $ch = curl_init(); | ||||
curl_setopt( $ch, CURLOPT_URL, $this->url ); | curl_setopt( $ch, CURLOPT_URL, $this->url ); | ||||
curl_setopt( $ch, CURLOPT_POST, true ); | curl_setopt( $ch, CURLOPT_POST, true ); | ||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $parms ); | curl_setopt( $ch, CURLOPT_POSTFIELDS, $parms ); | ||||
curl_setopt( $ch, CURLOPT_ENCODING, '' ); | curl_setopt( $ch, CURLOPT_ENCODING, '' ); | ||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); | ||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'IEG Grant review 0.1' ); | curl_setopt( $ch, CURLOPT_USERAGENT, 'IEG Grant review 0.1' ); | ||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |||||
'Accept: text/html; profile="mediawiki.org/specs/html/1.1.0"', | |||||
) ); | |||||
$stderr = fopen( 'php://temp', 'rw+' ); | $stderr = fopen( 'php://temp', 'rw+' ); | ||||
curl_setopt( $ch, CURLOPT_VERBOSE, true ); | curl_setopt( $ch, CURLOPT_VERBOSE, true ); | ||||
curl_setopt( $ch, CURLOPT_STDERR, $stderr ); | curl_setopt( $ch, CURLOPT_STDERR, $stderr ); | ||||
$body = curl_exec( $ch ); | $body = curl_exec( $ch ); | ||||
rewind( $stderr ); | rewind( $stderr ); | ||||
$this->logger->debug( 'Parsoid curl request', array( | $this->logger->debug( 'Parsoid curl request', array( | ||||
'method' => __METHOD__, | 'method' => __METHOD__, | ||||
'url' => $this->url, | 'url' => $this->url, | ||||
Show All 23 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 3.0 (CC-BY-SA) unless otherwise noted; code licensed under GNU General Public License (GPL) or other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL