Skip to content

Commit

Permalink
- First effort at adding pnut.io posting capability
Browse files Browse the repository at this point in the history
  • Loading branch information
dg01d committed Jul 3, 2017
1 parent 8cf6fcf commit 4d1ab5c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
24 changes: 23 additions & 1 deletion create.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 62,14 @@ function ping_micro_blog($url) {
$text = $_POST['something'];
$pass = $_POST['nothing'];

if ($pass == $configs->password){
if (hash('sha256', $pass) === $configs->password) {
reset($wp_comments);

$knownlink = '';
$twitlink = '';
$mastodonlink = '';
$tenclink = '';
$pnutlink = '';

$errors = array_filter($wp_comments);
if (empty($errors)) {
Expand Down Expand Up @@ -127,6 128,26 @@ function ping_micro_blog($url) {
echo $knownlink . " ";
}
// Known part over

// pnut.io part starts

if ($configs->postPnut) {
$pnutText = str_replace("\'", "'", $text);
$pnutText = str_replace("\"", "\"", $pnutText);
$pnutText = urlencode($pnutText);
$pnutToken = "Bearer " . $configs->pnutauthtoken;
$data = array(
"text" => $pnutText,
);

$the_result_pnut = post_to_api('https://api.pnut.io/v0/posts', $pnutToken, $data);
$the_array_pnut = json_decode($the_result_pnut, true);
$pnutlink = "https://posts.pnut.io/" . $the_array_pnut['data']['id'];
echo $pnutlink;
echo "<br>";
}

// pnut.io part ends

// 10Centuries PART STARTS
if ($configs->postTenc) {
Expand Down Expand Up @@ -236,6 257,7 @@ function ping_micro_blog($url) {
'comment_ID' => $comment_id,
'known' => $knownlink,
'blurb' => $tenclink,
'pnost' => $pnutlink,
'toot' => $mastodonlink,
'tweet' => $twitlink
);
Expand Down
44 changes: 41 additions & 3 deletions tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 5,51 @@
$configs = include('configs.php');

$json = '
{"location":"https:\/\/hylozoist.ascraeus.org\/2017\/did-a-lot-of-gardening-stuff-today-putting-pic-of"}
{
"meta": {
"code": 201
},
"data": {
"created_at": "2016-12-22T14:49:16Z",
"guid": "43414D15-AF76-448E-8FB0-B8CABBB325A9",
"id": "2392",
"source": {
"id": "3PFPMSet53RutGINA8e5HWqYg_UCDHad",
"link": "http://xyz.s3rv.com",
"name": "Broadsword"
},
"thread_id": "2392",
"counts": {
"bookmarks": 0,
"reposts": 0,
"replies": 0,
"threads": 0
},
"content": {
"html": "<span itemscope=\"https://pnut.io/schemas/Post\"><span data-tag-name=\"system\" itemprop=\"tag\">#system</span> of a duck</span>",
"text": "#system of a duck",
"entities": {
"links": [],
"mentions": [],
"tags": [
{
"len": 7,
"pos": 0,
"text": "system"
}
]
}
},
"you_bookmarked": false,
"you_reposted": false
}
}
';

$arrayName = json_decode($json, true);
//echo $arrayName['meta']['server'];
$link = $arrayName['location'];
echo $link. "\n";
var_dump($arrayName['data']['id']);
//echo $link. "\n";


// 'userName'
Expand Down

0 comments on commit 4d1ab5c

Please sign in to comment.