When trying to query Google Firebase dynamic link stats I am getting an empty object.
I've got 5 dynamic links in the firebase console which were created via the console. Using the following code I am able to get a token. I used the GCP->IAM->Service Accounts to create a new account and pull down the JSON file. I've ensured the project_id matches the one in firebase.
link = "my_dynamic_link_short_name"
scopes = ["https://www.googleapis.com/auth/firebase"]
credentials = service_account.Credentials.from_service_account_file("key.json", scopes=scopes)
url_base = "https://firebasedynamiclinks.googleapis.com/v1/SHORT_DYNAMIC_LINK/linkStats?durationDays=1"
encoded_link = urllib.parse.quote(link, safe='')
url = url_base.replace('SHORT_DYNAMIC_LINK', encoded_link)
request = Request()
credentials.refresh(request)
access_token = credentials.token
HEADER = {"Authorization": "Bearer " + access_token}
response = requests.get(url, headers=HEADER)
print(response.json())
Both of the above requests return a 200 but no data returned.
The GCP service account I am using has the following roles:
Firebase Admin
Firebase Admin SDK Administrator Service Agent
Service Account Token Creator
I've given it full owner to test and it didn't resolve issue.
FDL Analytics REST API returns an empty object {} if the short link doesn't have analytics data on the specified date range. If you have existing short links in the FDL dashboard that has click data, you can use it to validate if the response from the API matches the data displayed on the dashboard.
If you're still having issues, I suggest filing a ticket https://firebase.google.com/support
Edit: To add, Firebase Dynamic Links click data are aggregated daily and should be updated the next day. For newly created links, give it a day or two for the click data to be updated. This applies on both click data from the API and the one displayed on the dashboard.
Related
i wold like to obtain info about an API but i get this error:**{"message":"You are not subscribed to this API."}**How can I solve this?My code is this one:
url = "https://imdb8.p.rapidapi.com/title/get-top-stripe"
querystring = {"currentCountry":"US","purchaseCountry":"US","tconst":""}
headers = {
'x-rapidapi-host': "imdb8.p.rapidapi.com",
'x-rapidapi-key': ""
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)```
One needs to subscribe to a particular API on RapidAPI Hub. You can do that by visiting the pricing page of an API. I believe you're using IMDb API. The Basic plan is free of this IMDb API.
You can subscribe to any API by following the steps below:
Search API -> Go to the Pricing page -> Choose a plan (according to your need) -> Click on Subscribe button.
Once you subscribed, you would be able to test and connect to an API.
Is there a possibility to retrieve access token just from script in aws lambda without user interaction in the next way? =>
url = f'https://{user}:{password}#api.stocktwits.com/api/2/oauth/authorize?client_id={client_id}&response_type=token&redirect_uri={redirect_uri}&scope=publish_messages'
response = requests.get(
url, allow_redirects=True
)
For this moment I only retrieve redirect to => https://api.stocktwits.com/api/2/oauth/signin?
There is a plethora of solutions for this question. I'm assuming you are redirecting to an oauth page where it's requesting a sign in form? If that is the case one way you could do it is drive that page with selenium and have it fill in the credentials for you then you will be able to retrieve the access token.
This is the function that I use for making a call to Workplace API. But I don't see the page_id in the workplace (as opposed to in other Facebook pages).
Has anyone come across the same issue? Any suggestions would be appreciated !!
def testFacebookPageData(page_id, access_token):
base = "https://graph.facebook.com/v2.4"
node = "/" + page_id
parameters = "/?access_token=%s" % access_token
url = base + node + parameters
req = urllib2.Request(url)
response = urllib2.urlopen(req)
data = json.loads(response.read())
print json.dumps(data, indent=4, sort_keys=True)
testFacebookPageData(page_id, access_token) //Function call
There are several ways to get a Workplace custom integration page ID (all badly documented by Facebook). The easiest one is to access your bot page: just search your custom integration name in Workplace search bar (you would be able to find it as if it were a regular user).
Your bot page URL should look like:
https://<your_community>.facebook.com/<custom_integration_name>-<page_id>/
The page ID is the last number of the URL (it is a 15-digit number).
Alternatively, you can also access this Facebook page:
https://developers.facebook.com/tools/debug/accesstoken/
And paste your custom integration access token to see some relevant information of your access token, like permissions, but also the Page ID. It is designed for Facebook, but it works for Workplace as well, since they both share basically the same API.
This is my first time dealing with logging in using Facebook credentials. I want to be able to query listings in Airbnb through my account. My original account in Airbnb is through Facebook login. Here is the sample request on airbnb page: http://airbnbapi.org/#login-by-facebook.
I am not sure where can I get my client_id and Facebook's access token. Although it does point to https://developers.facebook.com/docs/facebook-login/access-tokens to get the user access token but, if I understand it correctly, it requires me to create an app. I am not sure what flow of authentication is required for me to use Airbnb API.
I have already looked at Airbnb docs to search for client_id but, of no use.
Here is what I have so far:
import requests
import json
API_URL = "https://api.airbnb.com"
LISTING_ENDPOINT= "https://api.airbnb.com/v2/search_results"
post_query = {
"client_id": "I HAVE NO IDEA WHERE TO GET IT",
"locale": "en-US",
"currency":"USD",
"assertion_type":"https://graph.facebook.com/me"
"assertion":"HOW SHOULD I GET THIS ONE?",
"prevent_account_creation":True
}
# I think this should be able to log me in and I should be able to query listings
_ = requests.post(API_URL, post_query).json()
query = {
"client_id":"FROM ABOVE",
"user_lat": "40.00",
"user_long":"-54.31"
}
listings = requests.get(LISTING_ENDPOINT, json=query).json()
I came across the same problem as you. I figure it out finally. The tool i used is the advanced function of requests library, that is Session(), for saving cookies. The important part for login with a third party account is to find the link we need to post the cookies. The following is my code.
import requests
x=requests.Session() #savig the cookies when you click the "log in with facebook button"
y=requests.Session() #saving the cookies for parsing the airbnb listing.
account={'email':'your_facebook_account','pass':'your_facebook_ps'}
log_in_with_facebook_click=x.post("https://www.airbnb.jp/oauth_connect?from=facebook_login&service=facebook")
#all the cookies up to now is saved in "x"
my_first_time_cookies=x.cookies.get_dict()
real_login_link=log_in_with_facebook_click.url
real_log_in=y.post(real_login_link,account,cookies=my_first_time_cookies)
#the real login link is saved in "log_in_with_facebook"
#pass the cookies and your facebook account information to the real login link
#you should have logged into airbnb.For testing the log in, we do the following. We check the reservation data.
from bs4 import BeautifulSoup
page=1
test=y.get("https://www.airbnb.jp/my_reservations?page="+str(page))
#Remember that the cookies we use to access airbnb website after loggin in is saved in "y"
test_html=BeautifulSoup(test.text,'lxml')
print(test_html.text)
#you should have looked your tenants reservation information.
Using Python:
from facepy import GraphAPI
key = 'My Access_Token'
a = GraphAPI(key)
response = a.get('Page_ID/posts')
print response
If I run this code, It shows me data in JSON format! And Limited Data. I want to get Years of feeds from my page.
In response I get Next tag URL: If I put this URL in Browser I can access more data. In one request we can fetch 200 feeds at a time.
How can I get data in bulk? I want to collect data of 5 years from public page!
Facebook's GraphAPI uses paging for API responses:
If you query v2.5/{page-id}/posts then the result will provide you with a data array and beneath this there is the paging section. You get the "previous" and "next" query string you just have to call again and again. API won't allow you more than 100 results per "page".