How to use Instagram graphql? - instagram

I'm using the following query
https://www.instagram.com/graphql/query/?query_id=17851374694183129&id={acountId}&first=1000&after={cursor}
to get an user followers. The information I need is the followed_by_count index that's only available per user on https://www.instagram.com/{username}?__a=1
Is there a query_id that includes the followed_by_count in the result?

This query_id code https://www.instagram.com/graphql/query/?query_id=17851374694183129&id=<user_id>&first=1000&after=<end_cursor> is designed to return ONLY media data it does NOT include user profile data.
The simplest solution is to use what IG uses on initial page requests:
https://www.instagram.com/<ig_username>/?__a=1
Here is my RubyOnRails setup:
profile = JSON.parse(open("https://www.instagram.com/<ig_username>/?__a=1").read)
... now grab your variables:
profile.['graphql']['user']['profile_pic_url']
profile.['graphql']['user']['biography']
profile.['graphql']['user']['external_url']
profile.['graphql']['user']['edge_followed_by']['count']
profile.['graphql']['user']['edge_follow']['count']
profile.['graphql']['user']['id']
profile.['graphql']['user']['edge_owner_to_timeline_media']['count']
profile.['graphql']['user']['profile_pic_url']
profile.['graphql']['user']['profile_pic_url_hd']
And your followed_by_count is now ['graphql']['user']['edge_followed_by']['count']

Related

How do I fetch data using user ID on StackAPI?

Is it possible to fetch data using StackAPI using UserID instead of "fromdate" or "questionID" etc?
I want to fetch the questions and tags used by a particular user.
What's the syntax for it.
I have tried
from stackapi import StackAPI
SITE = StackAPI('stackoverflow')
SITE._api_key = None
associated_users = SITE.fetch('/users/{}/associated'.format(10286273),
pagesize=1)
associated_users
But I don't know how to print data from it.
I don't see how "associated" is relevant to your stated goal.
You are interested in queries like:
tags = SITE.fetch('/users/{}/tags'.format(10286273), site='stackoverflow')
questions = SITE.fetch('/users/{}/questions'.format(10286273), site='stackoverflow')
which retrieve details on seven posts,
mentioning tags like python and chatbot.
cf https://api.stackexchange.com/docs/questions-by-ids

Stripe: Getting Credit Card's Last 4 Digits

I have upgraded the Stripe.net to the latest version which is 20.3.0 and now I don't seem to find the .Last4 for the credit card. I had the following method:
public void CreateLocalCustomer(Stripe.Customer stipeCustomer)
{
var newCustomer = new Data.Models.Customer
{
Email = stipeCustomer.Email,
StripeCustomerId = stipeCustomer.Id,
CardLast4 = stipeCustomer.Sources.Data[0].Card.Last4
};
_dbService.Add(newCustomer);
_dbService.Save();
}
But now the stipeCustomer.Sources.Data[0].Card.Last4 says 'IPaymentSource' does not contain a definition for 'Card'. Does anyone know how I can get the card details now? The flow is that I create the customer by passing the Stripe token to Stripe, then I get the above stripeCustomer. So I expect it to be somewhere in that object. But I can't find it. The release notes can be found here.
Thank you.
In the old world of Stripe, there only used to be one type of payment method you could attach to a Customer; specifically, Card-objects. You would create a Card-object by using Stripe.js/v2 or the Create Token API Endpoint to first create a Token-object and then attach that token to a Customer-object with the Create Card API Endpoint.
Once Stripe expanded to support a number of other payment methods though, Stripe built support for a new object type that encapsulated a number of payment methods (including credit cards) called Source-objects. A Source-object is created either by using Stripe.js/v3 or the Create Source API Endpoint. It can also be attached to a Customer-object in much the same way as the Card-objects mentioned above, except they retain their object type. They're still a Source. You use the Attach Source API Endpoint to do this (that is notably identical to the Create Card API Endpoint mentioned above).
What I'm getting at here, is there are now two different object types (or more) that you can expect to see returned in the sources-array (or Sources in .NET). All of these methods though inherit from the IPaymentSource-interface. So if you know you have a Card-object getting returned, you can simply cast the returned object to the Card-class.
Something like this should get you going:
CardLast4 = ((Card) stipeCustomer.Sources.Data[0]).Last4
You can see what I mean by inheritance by looking at this line in the Card-class file:
https://github.com/stripe/stripe-dotnet/blob/master/src/Stripe.net/Entities/Cards/Card.cs#L7
Good luck!
As of Stripe.net.21.4.1, this is what works:
var chargeService = new ChargeService();
var charge = chargeService.Get(id);
CardLast4 = ((Card)charge.Source).Last4;
It's getting hard not to panic when code breaks because of all the micro-changes Stripe makes.
So after debugging, it looks like the Data[0] needs to be cast as Card to get the card.
So it will be CardLast4 = ((Card)stipeCustomer.Sources.Data[0]).Last4.

unable to use 'include_docs' in fetchRevs as it is neither in BulkFetchDocsWrapper interface nor in DocumentFetchParams interface

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/bb1cc0e143f40f52a8d771e93036fc211df85cfb/types/nano/index.d.ts#L160
i am new to couch db and i know, i can use "fetch" if i want doc in result but i want doc in result based on some conditions when called with start_key and end_key. any help would be appreciated.
fetchRevs(
docnames: BulkFetchDocsWrapper,
params: DocumentFetchParams,
callback?: Callback<DocumentFetchRevsResponse>
): Request;
The fetchRevs endpoint is probably not what you want. I would take a look at the CouchDB API Overview and use:
PUT /mydb to create a database
PUT /mydb/docid to create a document in a database
GET /mydb/_all_docs?include_docs=true to retrieve all the documents
POST /mydb/_find to query the database
These API endpoints are modelled in the Typescript definition file you reference together with URLs that reference the API equivalents.

infusionsoft contact field query with python

I know how to connect to Infusionsoft with Python 3 and how to process the following simple example:
#Set up the contact data we want to add
contact = {}; #blank dictionary
contact[“FirstName”] = “John”;
contact[“LastName”] = “Doe”;
contact[“Email”] = "john#doe.com";
contact[“Company”] = “ACME”;
But how do I mass update the WHOLE database? e.g. If I want to update ALL The Phone1 fields with an extra bit of code using IF statements.
Using Infusionsoft API you can only update contacts data one by one, sending a separate request per contact. Exact request depends on which type of API you use: REST or XML-RPC

How to count number of activities in a getstream feed?

Does getstream provide a way to retrieve the number of activities within a feed? I have a notification feed setup. I can retrieve the activities using paginated get. However, I would like to display the number of items within the feed.
Unfortunately not, there is no API endpoint to retrieve the amount of activities within a feed.
At the moment there's no way to count activities directly. You can try
Use a custom feed and use reactions. So now you call count from reactions.
Other way is store in your app (cache/db/etc).
It worked for me:
signature = Stream::Signer.create_jwt_token('activities', '*', '<your_secret>', '*')
uri = URI("https://us-east-api.stream-io-api.com/api/v1.0/enrich/activities/?api_key=<api_key>&ids=<id1,id2,...>&withReactionCounts=true")
req = Net::HTTP::Get.new(uri)
req['Content-Type'] = "application/json"
req['Stream-Auth-Type'] = "jwt"
req['Authorization'] = signature
res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) {|http|
http.request(req)
}
puts JSON.parse(res.body)
References:
Retrieve
reactions_read-feeds
activities
ruby client
Update 2022
You can only get the number of activities in groups within aggregated or notification feeds. Flat feeds are still not supported.
Source
The best solution is to store important numbers in the database which Stream provides.
Source

Resources