Skip to content

Commit

Permalink
First implementation for ticket PressForward#994
Browse files Browse the repository at this point in the history
Simple GET request to the archive.org server
  • Loading branch information
yoannspace committed Apr 9, 2019
1 parent 503c019 commit 8fa6fe6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Core/Bookmarklet/NominateThisCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ public function nominate_it( $internal = true ) {
$post_ID = pressforward( 'utility.forward_tools' )->bookmarklet_to_nomination( false, $post );
}

// Sending a request to archive.org to be able to submit the URL of the source post
if( pressforward( 'utility.internet_archive' )->send_request_to_archive_dot_org( $post['guid'] ) ) {
pf_log( "The URL " . $post['guid'] . " was successfully provided to archive.org" );
}

if ( ! empty( $_POST['item_feat_img'] ) && ( $_POST['item_feat_img'] != '' ) ) {
pressforward( 'schema.feed_item' )->set_ext_as_featured( $post_ID, $_POST['item_feat_img'] );
}
Expand Down
8 changes: 8 additions & 0 deletions Core/Providers/UtilityProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Intraxia\Jaxion\Assets\ServiceProvider as ServiceProvider;

use PressForward\Core\Utility\Forward_Tools;
use PressForward\Core\Utility\Internet_Archive;
use PressForward\Core\Utility\Relate;
use PressForward\Core\Utility\Retrieval;

Expand Down Expand Up @@ -44,6 +45,13 @@ function( $container ) {
}
);

$container->share(
'utility.internet_archive',
function( $container ) {
return new Internet_Archive();
}
);

// parent::register( $container );
}
}
29 changes: 29 additions & 0 deletions Core/Utility/Internet_Archive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: yoann
* Date: 2019-04-09
* Time: 10:08
*/

namespace PressForward\Core\Utility;


class Internet_Archive {
function __construct() {

}

/**
* @param $url The URL of a page we want to be saved on archive.org
*
* @return bool|string TRUE if successful, FALSE if not
*/
function send_request_to_archive_dot_org( $url ) {
pf_log("Send to archive.org!");
$ch = curl_init( 'https://web.archive.org/save/' . $url );
$result = curl_exec($ch);

return $result;
}
}

0 comments on commit 8fa6fe6

Please sign in to comment.