create account

Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls) by justyy

View this thread on: hive.blogpeakd.comecency.com
· @justyy · (edited)
$128.21
Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)
[Utopian Moderators & Supervisors](https://chrome.google.com/webstore/detail/utopian-moderator-supervi/dcjdbldgiiboblbaconadffdaicicebc) is a Chrome Extension that has iterated for 12 versions, however, sadly, since last time [Utopian revokes for all API calls](https://steemit.com/utopian-io/@utopian-io/you-ask-we-deliver-new-reputation-system-new-decentralised-scoring-system-and-much-more) the Chrome Extension is virtually dead i.e. all API calls to `https://api.utopian.io/api` return 500 internal server error.

I submitted a support ticket asking for the [utopian](https://helloacm.com/make-utopian-moderator-chrome-extension-perfect-by-adding-posts-and-tools-tab/) API key but got rejected because:

> A API key must not be given out to end users and/or other developers. 
An API Key is bind to one ore more domains. From which domain/domains will you send the requests. At the moment we can only provide API keys suiteable for ajax requests made from websites in a browser.

Luckily, at the [London Cryptocurrency Show](https://steemit.com/promo-steem/@justyy/london-cryptocurrency-show-steem-is-the-no-1-blockchain-in-the-world) I met @wehmoen who is the leading developer (staff) at @utopian-io  therefore I managed to persuade him giving me the API key by proposing that I will wrap the API key on my server and change all API calls in the chrome extension to my API server, where I will hide all the API key/secret in my server.

Therefore, with the changes commited [here](https://github.com/DoctorLai/utopian-moderator/commit/917b5726e2631d11c8df7fbce8c194699f47c59d), the Utopian Moderators v0.0.13 is back to life!

You can install the extension at [Chrome Webstore](https://chrome.google.com/webstore/detail/utopian-moderator-supervi/dcjdbldgiiboblbaconadffdaicicebc).  For Opera browsers, the workaround is to first install[this](https://addons.opera.com/en/extensions/details/download-chrome-extension-9/) and similarly for Firefox, you can install [Chrome Store Foxified](https://addons.mozilla.org/en-US/firefox/addon/chrome-store-foxified/) before you install Utopian Moderators & Supervisors.

## API wrapping in PHP
```
<?php
/*
  utopian api wrapper at server side
  thanks to @wehmoen for providing me api key
*/
define("ORIGIN", "");
define("API_KEY", "");
define("API_KEY_ID", "");
function CallAPI($url, &$error, $data = null, $headers = null) {
  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  if ($headers) {
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  }
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
  $response = curl_exec($curl);
  $data = json_decode($response);
  /* Check for 404 (file not found). */
  $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  // Check the HTTP Status code
  switch ($httpCode) {
    case 200:
        $error = 200;
        break;
    case 404:
        $error = 404;
        break;
    case 500:
        $error = 500;
        break;
    case 502:
        $error = 502;
        break;
    case 503:
        $error = 503;
        break;
    default:
        $error = $httpCode;
        break;
  }
  curl_close($curl);
  return ($data);  
}    
$api = $_GET['api'] ?? '';
if (!$api) {
  die();
}

// avoid hacking to get the keys
$host = strtolower(parse_url($api, PHP_URL_HOST));
if ($host != 'api.utopian.io') {
  die();
}

$headers = array("Origin: " . ORIGIN, "x-api-key: " . API_KEY, "x-api-key-id: " . API_KEY_ID);
$err = '';
$data = CallAPI($api, $err, null, $headers);
header("Access-Control-Allow-Origin: *");  
header('Content-Type: application/json');
if ($err === 200) {
  die(json_encode($data));
} else {
  die(json_encode(array("error" => $err, "raw" => $data)));
}
```

![image.png](https://cdn.utopian.io/posts/35d33c583b7a503e67f3b411acbb9b2b3e67image.png)

PS: just confirmed with @wehmoen  the `https://utopian.plus/unreviewedPosts.json` is not working anymore and unfortunately there is currently no suitable API calls for this purpose. 

Long live @utopian-io !



Reposted to [my blog](https://helloacm.com/revive-utopian-chrome-extension-wrapping-utopian-api-calls/) for better indexing and archiving.


-----------------------------------
## Support me and my work as a [witness](https://steemit.com/witness-category/@justyy/justyy-just-another-witness) by 
1. voting me [here](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=justyy), or
2. voting me as [a proxy](https://v2.steemconnect.com/sign/account-witness-proxy?proxy=justyy&approve=1).

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@justyy/revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 64 others
properties (23)
authorjustyy
permlinkrevive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls
categoryutopian-io
json_metadata"{"community":"utopian","app":"steemit/0.1","format":"markdown","repository":{"id":119434075,"name":"utopian-moderator","full_name":"DoctorLai/utopian-moderator","html_url":"https://github.com/DoctorLai/utopian-moderator","fork":false,"owner":{"login":"DoctorLai"}},"pullRequests":[],"platform":"github","type":"development","tags":["utopian-io","witness-category","software-development","programming","steemstem"],"users":["wehmoen","utopian-io"],"links":["https://chrome.google.com/webstore/detail/utopian-moderator-supervi/dcjdbldgiiboblbaconadffdaicicebc","https://steemit.com/utopian-io/@utopian-io/you-ask-we-deliver-new-reputation-system-new-decentralised-scoring-system-and-much-more","https://helloacm.com/make-utopian-moderator-chrome-extension-perfect-by-adding-posts-and-tools-tab/","https://steemit.com/promo-steem/@justyy/london-cryptocurrency-show-steem-is-the-no-1-blockchain-in-the-world","https://github.com/DoctorLai/utopian-moderator/commit/917b5726e2631d11c8df7fbce8c194699f47c59d","https://addons.opera.com/en/extensions/details/download-chrome-extension-9/","https://addons.mozilla.org/en-US/firefox/addon/chrome-store-foxified/","https://helloacm.com/revive-utopian-chrome-extension-wrapping-utopian-api-calls/","https://steemit.com/witness-category/@justyy/justyy-just-another-witness","https://steemconnect.com/sign/account_witness_vote?approve=1&witness=justyy","https://v2.steemconnect.com/sign/account-witness-proxy?proxy=justyy&approve=1","https://utopian.io/utopian-io/@justyy/revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls"],"image":["https://cdn.utopian.io/posts/35d33c583b7a503e67f3b411acbb9b2b3e67image.png"],"moderator":{"account":"amosbastian","time":"2018-04-16T10:08:31.975Z","pending":false,"reviewed":true,"flagged":false},"questions":null,"score":null,"total_influence":null,"staff_pick":null,"config":{"questions":[{"question":"How would you rate the impact of the fixed bugs / new features on the project?","question_id":"dev-1","answers":[{"answer":"Very high - the amount of work is very high.","answer_id":1,"value":20},{"answer":"High - the amount of work is high","answer_id":2,"value":15},{"answer":"Average - the amount of work is average","answer_id":3,"value":10},{"answer":"Low - the amount of work is low.","answer_id":4,"value":5},{"answer":"Very Low - the amount of work is very little.","answer_id":5,"value":0}]},{"question":"How would you rate the quality of the provided code?","question_id":"dev-2","answers":[{"answer":"Very high - the code follows all the best practices and/or is the opposite of trivial.","answer_id":1,"value":20},{"answer":"High - the code follows nearly all the best practices and/or is not trivial at all. ","answer_id":2,"value":15},{"answer":"Average - the code follows most the best practices and/or some parts of it are trivial.","answer_id":3,"value":10},{"answer":"Low - the code doesn't really follow the best practices and/or a lot of it is trivial.","answer_id":4,"value":5},{"answer":"Very low - the code doesn't follow the best practices and is completely trivial.","answer_id":5,"value":0}]},{"question":"How do you rate the target project overall?","question_id":"dev-3","answers":[{"answer":"Very high - the project has a unique value, will (potentially) also be useful to a lot of people and has the potential to keep growing.","answer_id":1,"value":10},{"answer":"High - the project isn't really unique but it is well maintained.","answer_id":2,"value":8},{"answer":"Average - the project is limited or not very well maintained.","answer_id":3,"value":4},{"answer":"Low - quality of the project overall is low.","answer_id":4,"value":2},{"answer":"Very low - quality of the project overall is very low and not well maintained.","answer_id":5,"value":0}]},{"question":"Does the writing style meet the Utopian standard considering formalness, informativeness and clarity of the content?","question_id":"c-1","answers":[{"answer":"It is formal, informative and well written with clear content.","answer_id":1,"value":10},{"answer":"It is informative with clear content but not formal enough.","answer_id":2,"value":5},{"answer":"The contribution could be more informative or contains unrelated information, formality and clarity of the content are good enough.","answer_id":3,"value":4},{"answer":"Not all sections were clear enough but overall holds value for the project.","answer_id":4,"value":2},{"answer":"Not at all.","answer_id":5,"value":0}]},{"question":"Was the provided category template for the editor followed?","question_id":"c-2","answers":[{"answer":"All points of the template were included with additional points as well.","answer_id":1,"value":5},{"answer":"The template was followed without additions.","answer_id":2,"value":4},{"answer":"The template was edited but the points were covered in different way.","answer_id":3,"value":3},{"answer":"Not all points of the template were covered in the contribution but the structure is clear enough.","answer_id":4,"value":3},{"answer":"The template was not followed but the structure is clear enough.","answer_id":5,"value":2},{"answer":"The contents are not clearly structured at all.","answer_id":6,"value":0}]},{"question":"Did the contributor tag other users?","question_id":"c-3","answers":[{"answer":"No other users were tagged by the contributor.","answer_id":1,"value":5},{"answer":"Used tags are reasonable and all tagged people are connected to the project and/or the contribution.","answer_id":2,"value":5},{"answer":"The contribution contains mentions of other users that are not directly related to the contribution but related in other ways.","answer_id":3,"value":2},{"answer":"The contributor misuses tagging of other users.","answer_id":4,"value":0}]},{"question":"Did the contributor ask for upvotes, resteems, follows or witness vote?","question_id":"c-4","answers":[{"answer":"No","answer_id":1,"value":5},{"answer":"Yes, but not in a way that disturbs readability. ","answer_id":2,"value":5},{"answer":"Yes.","answer_id":3,"value":0}]},{"question":"Was a graphical content like images, charts, videos or screenshots included?","question_id":"c-5","answers":[{"answer":"Yes, the graphical content is included and adds more value to the contribution.","answer_id":1,"value":5},{"answer":"No but the contribution works well without graphical content well.","answer_id":2,"value":4},{"answer":"Yes, but most of the graphical content’s purpose is just for presentational matters.","answer_id":3,"value":3},{"answer":"No relevant or useful graphical content is included in the contribution.","answer_id":4,"value":0}]},{"question":"How would you rate the overall added value?","question_id":"c-6","answers":[{"answer":"Extraordinary value to both the project and the open source community overall.","answer_id":1,"value":20},{"answer":"Significant value to the project or open source community.","answer_id":2,"value":15},{"answer":"Some value to the project or open source community.","answer_id":3,"value":10},{"answer":"Little value to the project or open source community.","answer_id":4,"value":5},{"answer":"No obvious value to project or open source community.","answer_id":5,"value":0}]}]}}"
created2018-04-15 17:49:36
last_update2018-04-16 15:28:00
depth0
children8
last_payout2018-04-22 17:49:36
cashout_time1969-12-31 23:59:59
total_payout_value97.577 HBD
curator_payout_value30.637 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,720
author_reputation280,616,224,641,976
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries
0.
accountutopian.pay
weight1,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,239,218
net_rshares28,617,011,089,820
author_curate_reward""
vote details (128)
@amosbastian · (edited)
Thanks for the contribution. It has been approved.

Cool! I might need to try something like this, since `utopian-cli` is currently dead as well.

----------------------------------------------------------------------
Need help? Write a ticket on https://support.utopian.io.
Chat with us on [Discord](https://discord.gg/uTyJkNm).

**[[utopian-moderator]](https://utopian.io/moderators)**
properties (22)
authoramosbastian
permlinkre-justyy-revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls-20180416t101116720z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"steemit/0.1","links":["https://support.utopian.io","https://discord.gg/uTyJkNm","https://utopian.io/moderators"]}
created2018-04-16 10:11:18
last_update2018-04-16 10:12:57
depth1
children0
last_payout2018-04-23 10:11:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length387
author_reputation174,473,586,900,705
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries
0.
accountutopian.pay
weight1,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,354,011
net_rshares0
@armonia ·
Hello @justyy.
Today I have left my vote, to support you as a witness.
That you continue contributing with your talent and kindness in the Steemit community.
Que estés siempre muy feliz.
properties (22)
authorarmonia
permlinkre-justyy-revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls-20180417t171516753z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["justyy"],"app":"steemit/0.1"}
created2018-04-17 17:15:24
last_update2018-04-17 17:15:24
depth1
children1
last_payout2018-04-24 17:15:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length186
author_reputation3,699,715,013,926
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,607,189
net_rshares0
@justyy ·
$0.05
Thank you very much.
👍  , , , ,
properties (23)
authorjustyy
permlinkre-armonia-re-justyy-revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls-20180417t195658032z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-17 19:56:57
last_update2018-04-17 19:56:57
depth2
children0
last_payout2018-04-24 19:56:57
cashout_time1969-12-31 23:59:59
total_payout_value0.048 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length20
author_reputation280,616,224,641,976
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,630,645
net_rshares9,739,311,367
author_curate_reward""
vote details (5)
@commonlaw · (edited)
Hey I just checked out a bunch of tools, toys, and awesome stuff you have made for streamians.  That being the case I saw your message  and just now voted for you as my witness. Just keep it up guy and I will stay happy. This one you talk about on the post looks great too.
properties (22)
authorcommonlaw
permlinkre-justyy-revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls-20180416t161720930z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-16 16:17:21
last_update2018-04-16 16:20:00
depth1
children2
last_payout2018-04-23 16:17:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length273
author_reputation3,267,008,243,675
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,408,075
net_rshares0
@justyy ·
$0.04
properties (23)
authorjustyy
permlinkre-commonlaw-re-justyy-revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls-20180416t181042129z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-16 18:10:57
last_update2018-04-16 18:10:57
depth2
children1
last_payout2018-04-23 18:10:57
cashout_time1969-12-31 23:59:59
total_payout_value0.042 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length20
author_reputation280,616,224,641,976
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,424,701
net_rshares8,626,240,772
author_curate_reward""
vote details (6)
@commonlaw ·
No justy thank you for us steemians.
properties (22)
authorcommonlaw
permlinkre-justyy-re-commonlaw-re-justyy-revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls-20180416t192652006z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-16 19:26:54
last_update2018-04-16 19:26:54
depth3
children0
last_payout2018-04-23 19:26:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length36
author_reputation3,267,008,243,675
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,435,926
net_rshares0
@ny4.one ·
I like this extention.. how  can i do for use it
properties (22)
authorny4.one
permlinkre-justyy-revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls-20180415t184043797z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-15 18:40:48
last_update2018-04-15 18:40:48
depth1
children0
last_payout2018-04-22 18:40:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length48
author_reputation93,052,898,061
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,246,301
net_rshares0
@utopian-io ·
### Hey @justyy I am @utopian-io. I have just upvoted you!
#### Achievements
- People loved what you did here. GREAT JOB!
- Seems like you contribute quite often. AMAZING!
#### Utopian Witness!
<a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness</a>

**Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
properties (22)
authorutopian-io
permlinkre-justyy-revive-utopian-chrome-extension-thanks-to-wehmoen-wrapping-utopian-api-calls-20180416t103618679z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-04-16 10:36:21
last_update2018-04-16 10:36:21
depth1
children0
last_payout2018-04-23 10:36:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length678
author_reputation152,955,367,999,756
root_title"Revive Utopian Chrome Extension thanks to @wehmoen ! (Wrapping Utopian API Calls)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,356,908
net_rshares0