how to get the feed activities of an user? - spotify-app

I am trying to get the activity feeds of a user for 2 days. After trying all sorts of things I got to the result, that I am getting an empty array.
Do I have to get some kind of authorization? But if so it should return something if I fetch my own feed. I used this code:
var snap = aFeed.activities.snapshot(0, 50);
console.log(snap);
and I am getting a Promise with empty arrays.

Guess there's no more need to answer this question because is not taking app submissions any more.
http://devnews.spotify.com/2014/03/24/closure-of-spotify-apps-submissions/

Related

How do i use this fetched data response?

I Am using react. I have a fetch setup in an useEffect to grab the data from a database from the backend. It pulls the account and sends it back to the front where i can access it from there.
From the File I want to access the user information i have a console log
I want to be able to grab like the firstname, lastname individually and use them in the script. how do i go about that. I did try to console log UserData.user and it gave me this result
However when i went to try to get firstname like userData.user.firstname i was met with an error. Im pretty new to react and pushing myself with things ive never done before to learn and any help would be great
Thank you everyone who does help it means alot
Please note all information in screenshots are fictitious and are just prop data.
EDIT:
This may be because you are trying to read the user information before the api returns the data. so check if the array has data before trying to access it . You can use save navigation to check for undefined or null
UserData.user[0]?.firstname
Based on your screenshot the data you are getting back is an array of user objects. To access it you will need to use:
userData.user[0].firstname
Note that this will access the first user object in the array - you will likely need checks to ensure the data data exists before accessing it, e.g.:
if (userData.user.length > 0) {
// Access data as needed
}
user is an array so you can acces like this
userData.user[0].firstname;
it will be better if you update your endPoint to get an object instead, so you can have access and check easier

How should I build a Fetch (Post) data array/structure from scratch? How do I join two arrays? Is it necessary for Fetch?

I need to build some kind of data structure/array starting with nothing and from a loop where the data is available. These would be key/value pairs. I tried initializing an empty cartData array [] in my javascript file, then using push, but this does not appear to be the right thing. This is a shopping cart program. I have all of the customer data captured in an array that looks like {First Name: firstName, Last Name: lastName, Email: emailAddress,... ,} and from the console it appears to have worked and in that form. For cartData, I'm getting something like
{Book_Title1: Price1},{Book_Title2: Price2},...{},{}
as a collection of objects. When I added to the cartData = [] array I gathered the data inside the loop and used the following method
cartData.push({[purchaseItem]: purchasePrice})
to add new items to the empty array. What I get is a collection of objects that look like
{BookTitle1: Price1}, {BookTitle2: Price2},...{}, {}
are the {}brackets unnecessary? There seem to be a number of opinions without examples. I was assuming that the first structure shown here is what is needed for Fetch to post the way a normally presents data. I could be wrong on that also. I need to know the correct way to do it and a way to combine the two data sets (three if we count the Key/Value pair for grand $total.) My goal is to have the customer hit the purchase button, the cart/form data to go to Formspree.io and for them to send an email with all of this order information. It works well enough with an unadulterated . I just need to amend the data for the cart.
It would help if you provide a snippet of the code that you've written, because it's not really clear what format are you sending the data in.
Your question seems to imply that you're sending the request body as an array. That is incorrect. It has to be a JSON.
Secondly make sure you add the 'Content-Type: application/json' header to your request

Triggering multiple webhooks with Zapier array of Json objects

I'm having trouble with triggering multiple webhooks via Zapier like explained on Zapiers website
Did anyone manage to use this functionality?
I'm trying to create "an array of properly formed JSON objects".
To be able to select it as data source in the next step it needs to be a simple array (thats why I stringify the jsons inside the array).
Here is the json array I'm creating in Zapier Code trying to use to trigger two separate webhooks being triggered
var jsonArray = ['{"id":1,"data":111}','{"id":2,"data":222}'];
output = {jsonArrayOut: jsonArray};
Here is a screenshot of a custom webhook request in Zapier
No matter how I format the data I always get one request, not two.
This is the result I see
Could anyone please tell me what am I missing?
Cool, so what you described in this comment should totally be possible.
Your zap will be the following:
Trigger - new email
Parse email, return an array of {id, data} (see below)
Update inventory (will happen for each item in the array in step 2)
This takes advantage of an undocumented feature of code steps where if they return arrays, the zap branches and subsequent steps run multiple times. Note that there's no UI for this and it'll look confusing, but it will work.
Your JS code will be something like the following:
// parse email code
// get items and their quantities
// return object that looks like this
return [{id: 1, data: 123}, {id: 2, data: 456}]
In step 3 (however you're doing that), you'll be able to select id and data as mappable inputs. When you're setting the zap up, you'll only see 1 and 123 as options, but when the zap is on and runs for real, step 3 will get run for each array element returned in step 2.
According to the docs:
You can send an array of properly formed JSON objects, and we will
trigger the Zap once for each object in the array.
Application will be able to parse through the json and understand its structure. Making it as a string makes it to lose it.
So I'm guessing sending it as a string might not work. The Application won't be able to find the number of elements inside the string, it will consider entire string to be one element.
Try,
output = [{"id": 1, "data": 111},{"id": 2, "data": 222}];

Is there any way to limit a Gmail watch to only messages added?

When setting up a watch for a user is there a way to limit the watch to only messages added to the inbox?
Based on the documentation (https://developers.google.com/gmail/api/v1/reference/users/watch) I see that there is the option for INBOX labelId, but I want to limit it to only messages added as well. We're currently having to handle this by passing 'history/messagesAdded' in the fields string in the subsequent history.list call.
Unfortunately you cannot. what you have to do is
Get the history when notification arrived. History returns a json and it contains a 'messagesAdded' if new message is added.
You can keep a predefined array of labels like below
predefinedLabels = ['UNREAD', 'CATEGORY_PERSONAL', 'INBOX']
Now you can check, (each is the history json)
if 'messagesAdded' in each:
labels = each["messagesAdded"][0]["message"]["labelIds"]
intersectionOfTwoArrays = list(set(predefinedLabels) & set(labels))
Here you get the intersection of labels. Now you have to check that with predefined labels
if set(predefinedLabels) == set(intersectionOfTwoArrays):
#get the messageId and do what you want
finally you can filter the notification as you want!.
It is better to store histroyId and update it with every
notification and use it when you get the history. It will help you
to get updated history only.
Please note I used python when I was building my sever. So above demo code written using python
It looks like history.list added a new parameter "historyTypes". If you set that to "messageAdded", the api will only return history records of that type.

Instagram API cursor loop

I'm doing some searching using the Instagram REST API. Specifically, the endpoint I'm using is /tags/{tag-name}/media/recent. I'm first getting the number of media items with the tag in question using /tags/{tag-name}, which is ~445K. I'm going through all the media items using the 'next_max_tag_id' that comes along with the response. I don't know how long this takes, but at some point, the max IDs start to loop. Not back to back, but as of ~250K, it's just constantly looping over the same 5 next_max_tag_id values.
Am I doing it wrong by counting the number of items I've processed and comparing it to the number of media items I'd previously gotten?
How do you know when you've reached the end of the list?
Look at the answer here:
Instagram realtime get post from callback
I think this scenario is the same as yours.

Resources