Looking to create a single function Twitter bot that sits on a webpage, takes a single text input, appends a URL, and returns a single data point – “is user following Account X?” Account X is a constant. Using Javascript. Building on Wix.com’s VeloAPI so some code might look different,
Incoming text input gets turned into variable twiHan (short for Twitter Handle.)
Wix HTML:
var twiHan = “initial”;
export function button3_click(event) {
twiHan = $w(‘#input2’).value;
console.log(twiHan);
Q: How do I overwrite the first secret’s value with this input text?
This function in the .jsw returns the value of the first secret.
export function getFirstSecretValue() {
return wixSecretsBackend.listSecretInfo()
.then((secrets) => {
return wixSecretsBackend.getSecret(secrets[0].name);
})
.catch((error) => {
console.error(error);
});
}
This function (currently minus Authorization code) will pull the first secret’s value, input it into the URL, perform the getJSON operation, and return something (at this point a Bad Authentication error, but server contact is happening, I’ll fill in the headers after I solve this basic code question. CORS is supported because Wix.com/Velo API I’m stuck using.
export async function getSecreto() {
try {
const secret = await getSecret(‘UserName’);
return getJSON(https://api.twitter.com/1.1/friendships/lookup.json?screen_name=${secret}
);
} catch (err) {
console.error(err);
}
}
The update/overwrite function could come before the getJSON function at the click event, but how do I update or overwrite the first Secret’s value with the variable value? I’ve been through the wix-secrets-backend API docs and it’s still not quite making sense to me.
And if you’re wondering about CORS - the Wix Velo API supports calls from backend web modules.
I’m sure I’ll have more question about Authentication but for now I just need to figure this part out. Thanks!