Discuss Scratch

NickyNouse
Scratcher
1000+ posts

Set cloud lists from http?

So in the api Scratch uses to GET cloud vars, there's an object for lists. Is it possible to set those with http requests? (I don't know anything about requests so I couldn't test this myself)

Has anyone even created a var this way, or just set them? You'd probs also have to add the list to the project's JSON.
Blue-Monkey
Scratcher
100+ posts

Set cloud lists from http?

Interesting… but I barely know anything about HTTP requests.

Blue-Monkey

Be a business owner!
Are you sure you know all the tricks of using Google?

;

Click here to find out how to bring back the Semicolon Glitch
Blue-Monkey
Scratcher
100+ posts

Set cloud lists from http?

Blue-Monkey wrote:

Interesting… but I barely know anything about HTTP requests.
http://www.w3schools.com/tags/ref_httpmethods.asp this website talks about HTTP requests

Blue-Monkey

Be a business owner!
Are you sure you know all the tricks of using Google?

;

Click here to find out how to bring back the Semicolon Glitch
Zaidhaan
Scratcher
100+ posts

Set cloud lists from http?

interesting! I must check it out. I'll try to set some variables on a test project

liam48D
Scratcher
1000+ posts

Set cloud lists from http?

Tell me the ajax request Scratch uses and I'll get right to it.

202e-202e-202e-202e-202e UNI-CODE~~~~~
NickyNouse
Scratcher
1000+ posts

Set cloud lists from http?

liam48D wrote:

Tell me the ajax request Scratch uses and I'll get right to it.
well I know the API to get vars is http://scratch.mit.edu/varserver/(project-id) (this is the one that includes the lists object)

The JS behind it has some other stuff that looks maybe relevant:
https://scratch.mit.edu/projects/(project-id)/cloud-data.js

Last edited by NickyNouse (May 30, 2015 09:34:30)

liam48D
Scratcher
1000+ posts

Set cloud lists from http?

NickyNouse wrote:

liam48D wrote:

Tell me the ajax request Scratch uses and I'll get right to it.
well I know the API to get vars is http://scratch.mit.edu/varserver/(project-id) (this is the one that includes the lists object)

The JS behind it has some other stuff that looks maybe relevant:
https://scratch.mit.edu/projects/(project-id)/cloud-data.js
Alright, taking a look.

202e-202e-202e-202e-202e UNI-CODE~~~~~
liam48D
Scratcher
1000+ posts

Set cloud lists from http?

Running on https://scratch.mit.edu/projects/64856068

var pid = 64856068;
var token = "INSERT TOKEN HERE"
createCookie("projectId", pid);
$.ajax({
    type: "POST",
    url: "/projects/purge-cloud-data/",
    data: {
        token: token
    },
    success: function(data) {console.log("SUCCESS");console.log(data);},
    async: false
});

As a quick clarification INSERT TOKEN HERE should be replaced with the token you find 2/3s down the page here. Not sure if it's the same for you and me so I've taken mine out, just in case.

Output for me:

[Warning] dat no async warning on Chrome
SUCCESS
Object {response: "ok"}
> Object {readyState: 4, responseText: "{'response': 'ok'}"...}

Wait I just looked up define purge, and it turns out it has something to do with abruptly removing something.. so did I just clear the cloud data on my project lol?

202e-202e-202e-202e-202e UNI-CODE~~~~~
liam48D
Scratcher
1000+ posts

Set cloud lists from http?

Meh, doesn't look like it has anything about setting cloud variables with JS.

202e-202e-202e-202e-202e UNI-CODE~~~~~
NickyNouse
Scratcher
1000+ posts

Set cloud lists from http?

liam48D wrote:

snip
this is all looking really cool I'mma peace out for the night, tomorrow we can work on setting vars (I feel like someone said they knew how to do it but I don't remember who )
liam48D
Scratcher
1000+ posts

Set cloud lists from http?

NickyNouse wrote:

liam48D wrote:

snip
this is all looking really cool I'mma peace out for the night, tomorrow we can work on setting vars (I feel like someone said they knew how to do it but I don't remember who )
Okay, see you tomorrow!

It's 7:20 in the morning for me. xD

202e-202e-202e-202e-202e UNI-CODE~~~~~
Firedrake969
Scratcher
1000+ posts

Set cloud lists from http?

The goal is to do stuff with cloud variables _just_ with JS ajax in the console, right?

'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
NickyNouse
Scratcher
1000+ posts

Set cloud lists from http?

Firedrake969 wrote:

The goal is to do stuff with cloud variables _just_ with JS ajax in the console, right?
That sounds easiest, but I know there's been talk of daemons constantly updating projects
liam48D
Scratcher
1000+ posts

Set cloud lists from http?

NickyNouse wrote:

Firedrake969 wrote:

The goal is to do stuff with cloud variables _just_ with JS ajax in the console, right?
That sounds easiest, but I know there's been talk of daemons constantly updating projects
Yep, it's all easiest to do by using an interval on a JS daemon sending a request to Scratch to set cloud data.

202e-202e-202e-202e-202e UNI-CODE~~~~~
gtoal
Scratcher
1000+ posts

Set cloud lists from http?

liam48D wrote:

Yep, it's all easiest to do by using an interval on a JS daemon sending a request to Scratch to set cloud data.

Yes, but some of us like to program in grown-up's languages :-/

G
liam48D
Scratcher
1000+ posts

Set cloud lists from http?

gtoal wrote:

liam48D wrote:

Yep, it's all easiest to do by using an interval on a JS daemon sending a request to Scratch to set cloud data.

Yes, but some of us like to program in grown-up's languages :-/

G
JavaScript isn't a grown-up language?

202e-202e-202e-202e-202e UNI-CODE~~~~~
NickyNouse
Scratcher
1000+ posts

Set cloud lists from http?

I'm pulling an OP here: I'd lean toward JS simply because I know it better than Python or any C-derived language
cuddley
Scratcher
100+ posts

Set cloud lists from http?

     override public function projectLoaded() : void
{
super.projectLoaded();
this.updateSaveStatus();
if(this.usesPersistentData)
{
if(this.isLoggedIn())
{
if(this.serverSettings && this.serverSettings.user_groups)
{
if(this.serverSettings.user_groups.indexOf("Scratchers") > -1)
{
this.persistenceManager.connectOrReconnect(projectID,this.serverSettings.cloud_data_host,this.serverSettings.cloud_data_fallback_host);
ExternalInterface.call("$.getScript","/projects/" + projectID + "/cloud-data.js");
}
else
{
this.jsSetProjectBanner("Because you have a new Scratch account, any changes to cloud data won\'t be saved yet. Keep participating on the site you\'ll be able to use cloud data soon!");
}
}
}
else
{
this.jsSetProjectBanner("This project uses Cloud data ‒ a feature that is available only to signed in users.");
}
}
this.jsReportStats();
if(!editMode && this.editAfterLoad)
{
this.editAfterLoad = false;
this.setEditMode(true);
}
}
Decompiled

Generation 3: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.

I don't know what to write.
cuddley
Scratcher
100+ posts

Set cloud lists from http?

      public function getLoadTimeCloudToken() : String
{
return loaderInfo.parameters["cloudToken"];
}
Decompiled

Generation 3: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.

I don't know what to write.
PullJosh
Scratcher
1000+ posts

Set cloud lists from http?

cuddley wrote:

      public function getLoadTimeCloudToken() : String
{
return loaderInfo.parameters["cloudToken"];
}
Decompiled
Please don't necropost - that is, post on old topics. It can clog up the forums by bringing old, unused topics back to the top of the page. Thanks!

Powered by DjangoBB