Page MenuHomePhabricator

Help Copyvio Detector migrate to a new API
Closed, ResolvedPublic8 Estimated Story Points

Description

Now that we're losing access to Yahoo's index, we need to migrate existing copyvio tools to using a different API.

Tool: http://tools.wmflabs.org/copyvios/

Related Objects

Event Timeline

DannyH set the point value for this task to 8.Mar 29 2016, 5:30 PM
DannyH triaged this task as Medium priority.Mar 29 2016, 5:39 PM

The authorization for the new API is done through a basic authorization header passed as part of the API request.

In PHP this would be implemented something like:

$accountKey = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
$webSearchURL = 'https://api.datamarket.azure.com/Bing/Search/Web?$format=json&Query=';
$context = stream_context_create(array(
  'http' => array(
    'request_fulluri' => true,
    'header'  => "Authorization: Basic " . base64_encode($accountKey . ":" . $accountKey)
  )
));
$request = $webSearchURL . urlencode( '\'' . $_POST["searchText"] . '\'');
$response = file_get_contents($request, 0, $context);
$jsonobj = json_decode($response);
Earwig claimed this task.

It works. Hallelujah.