RE: RE: testing cross chain post
You are viewing a single comment's thread from:

RE: testing cross chain post

Words
126
Reading
1 min
Listen
Play
7y

Pseudo copy and paste. Be aware that the steem/hive chain doesn't like some characters common to coding-also some characters could have been lost converting it to a somewhat hive chain friendly format.

Checkout the time stamp of https://palnet.io/testing/@firstamendment/testing-crosschain-post with this time stamp of the original post here.

<?php

//insert refresh codes.
$code="refresh_code1";
$code2="refresh_code2";

//insert your secret that you stored at steemconnect, if any.
$secret="";
$secret2="";

//does https request to access and parse page with new access token.

$ch = curl_init("https://api.steemconnect.com/api/oauth2/token");
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,"code=".$code."&client_secret=$secret");
$result="";
if (($result=curl_exec($ch)) === false) {}
$accesstoken=substr($result,strpos($result,":")+2,strpos($result,".")-16);

$ch = curl_init("https://hivesigner.com/api/oauth2/token");
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,"code=".$code2."&client_secret=$secret2");
$result="";
if (($result=curl_exec($ch)) === false) {}
$accesstoken2=substr($result,strpos($result,":")+2,strpos($result,".")-16);

//if new post leave blank, else if comment original author
$name="";
//Your user name
$user="firstamendment";
//if a new post leave a single tag, else use author's permlink.
$path="testing";
//unique identifier; your permlink. if comment, may want to make $path.time().
$path2="testing-crosschain-post";
//title of post
$title="testing cross chain post";
//tags. if none leave as "\\\"\\\"". else "\\\"tag1\\\",\\\"tag2\\\",\\\"tag2\\\"..."
$cat="\\\"palnet\\\",\\\"stem\\\",\\\"coding\\\",\\\"steem\\\",\\\"hive\\\",\\\"bot\\\"";

//strangely new line characters need not a "\n" but a "\\n", per reason of json.
$data="testing crosschain posting";
$json = "{\"operations\": [[\"comment\",{\"parent_author\":\"".$name."\",\"parent_permlink\":";
$json.="\"".$path."\", \"author\" : \"".$user."\", \"permlink\" : \"".$path2;
$json.="\",\"title\" : \"".$title."\", \"body\":";
$json.="\"".$data."\", \"json_metadata\":\"{\\\"tags\\\":[".$cat."]}\"}]";
$json.=",[\"comment_options\", {\"author\": \"".$user."\", \"permlink\":\"".$path2."\", \"title\":\"".$title."\",\"max_accepted_payout\": \"1000000.000 SBD\", \"percent_steem_dollars\": 0, \"allow_votes\": true,\"allow_curation_rewards\": true, \"extensions\": []}]]}";
echo "\n<br>".$json;

$ch = curl_init("https://api.steemconnect.com/api/broadcast");
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json, text/plain, */*','authorization: '.$accesstoken,'content-type: application/json','DNT:1','Origin: http://127.0.0.1:8080/php.steem.php','','Sec-Fetch-Mode: cors','User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'));
if (($result=curl_exec($ch)) === false) {}
echo "\n<br>r1:".$result;

$ch = curl_init("https://hivesigner.com/api/broadcast");
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json, text/plain, */*','authorization: '.$accesstoken2,'content-type: application/json','DNT:1','Origin: http://127.0.0.1:8080/php.steem.php','','Sec-Fetch-Mode: cors','User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'));
if (($result=curl_exec($ch)) === false) {}
echo "\n<br>r2:".$result;
?>