Definning a timerange with insights - facebook-graph-api

I'm attempting to retrieve the clicks and impressions in a time range for all campaigns. According to the documentation the following should work, but it returns everything unbound by date.
https://graph.facebook.com/v2.8/act_560058834176764/campaigns?fields=id,name,insights.fields(clicks,impressions)&time_range[since]=2016-10-02&time_range[until]=2016-10-03&access_token=EAAWwyqCJfOkBAPYtFTXsh6JZBUWZCIsNaHTrLKpKVY2VmINwmZA8R8FPUpbe8rNU7nWRqXNrMlI0tMMrAjLrkzTMIfWSfu2DDn4YtauZBatQGhAKv2Raxd38d0Dj00O8sX9zHk5TwdtyPh0jxzW6cUdseg8Uah8LYqicaoaJA9QJVT0OCvEm
Any ideas? Do I have the format wrong or something?

you can use the following to get campaign level insights for certain time_range:
act_<ACCOUNT_ID>/insights?level=campaign&time_range={"since":"2016-10-02","until":"2016-10-03"}

Related

Power BI Embedded deleteVisual usage in a layout file

I am trying to use the await page.deleteVisual("8d0e01e7a860c2e5706d"); command when I layout a report page. This seems logical to me. I am going to place various visuals on the page for a certain group of people. For another group of people I will delete a few other visuals and keep this one. I get the following error:
TypeError: report.deleteVisual is not a function at changeLayout (PQLayout.js:56)
Most of the documentation pages are bare and lacking good examples, but this page doesn't help much for the error: https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/remove-visual
Thanks
deleteVisual is a method provided by the Page object but from the error it seems you are calling it for the report object. You should use page.deleteVisual("VISUAL_GUID") to delete the visual.
deleteVisual is a method of powerbi-report-authoring SDK.
You can refer to the live showcase to understand the usage of this SDK:
Live showcase: Quickly create and personalize visuals
Showcase's source code: https://github.com/microsoft/PowerBI-Embedded-Showcases/tree/main/Quickly%20create%20and%20personalize%20visuals
Docs: https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/remove-visual

Can I get the data of those whom I am not following on twitter?

I seem to be having problems with this in the twitter API.
I want the global data from the API which includes :
1. All those posts from the users I am following.
2. All those posts from the users I am not following.
Is this possible with the twitter API ? Has anyone tried it before ?
I'm using python, but any type of answer would be helpful.
Yes it is possible.
What you can do is say create a list of customers(those whom you follow) in a database...now check for each tweet if it from your customer then pass if not then do as desired.
if you can get data of those whom you are following then you can also get data of those whom you are not following

Getting the facebook graph to only return results with a # symbol in it

Any one have any ideas on how to accomplish this?
I have tried
https://graph.facebook.com/search?q=%22%23apple%22
https://graph.facebook.com/search?q=%23apple
https://graph.facebook.com/search?q#apple
which does not work.
To be clear the results should only have posts that contain #apple not "apple".
Facebook says this is not supported at this time: https://developers.facebook.com/x/bugs/313941462054417/
if you're trying to get the #hashtags from Facebook, currently, there is no api for this. and even if there were- the posts are not intermediate, they are being cached. you won't see the most recent hashtag from a person who's not in your friendlist right away, this will take a long time to appear in the hashtag search
I've read too that it's not supported but,
trying the second line of jlarry
https://graph.facebook.com/search?q=%23apple
in Graph API Explorer, it works.
obviously the query is on the posts set as public.
so the query could be something like this
https://graph.facebook.com/search?q=%23joviberton‬&type=post
for further ops check https://developers.facebook.com/docs/graph-api/using-graph-api/

Facebook Graph API Filters - What options are available?

It seems that you can make a call to the Graph API that looks like this:
https://graph.facebook.com/me/checkins?since=yesterday
Apparently you can pass either a UNIX timestamp or any valid strtotime value.
The questions...how do you know what other options are available to you in the request? I don't see any documentation about this "since" filter or any other similar filter. Is this information just trickling down from people who know some API engineers at Facebook?
I know that there are some things that you can do in FQL that are similar to what I was describing but I want to stay with the Graph API if I can.
Thanks
--Tony
Anothony Lee:
since, until - (a unix timestamp or any date accepted by strtotime):
EG: since=yesterday until=now, since=6+months+ago until=3+months+ago,
since=10/01/2011 until=10/11/2011
another example
&since=noon+monday+last+week &until=10+minutes+ago.
you need to provide the date filter as shown in the below link. time_range should be attached to the insights.
try this
https://graph.facebook.com/v6.0/me?fields=id%2Cname%2Cadaccounts%7Bcampaigns%7Badsets%7Bads%7Binsights.time_range(%7B'since'%3A'2020-05-01'%2C'until'%3A'2020-05-01'%7D)%7Badset_id%2Ccampaign_id%2Cad_id%2Cclicks%7D%7D%7D%7D%7D&access_token=

I need a sunrise/sunset webservice api

Anyone know of a good webservice or api that I can use to get the sunrise/sunset times in bulk? Every thing I have found so far only gives a day at a time or has a limitation on what dates can be used.
http://sunrise-sunset.org/api
It's free to use. Just needs a credit link back to the website.
It's not a web service, but this SO question has links to algorithms, so you can create a table or your own web service with all the dates you need.
I recently found this JavaScript library that performs calculation based on date and lat/lon coordinates. It seems to be very precise.
Link: https://github.com/mourner/suncalc
It is also available as NodeJs package through npm.
NASA has the calculation in nicely laid out JS. View the source of this page:
http://www.esrl.noaa.gov/gmd/grad/solcalc/
NOTE: I'm not a lawyer but I believe the US Government cannot copyright anything, hold patents, etc. so one should be able to copy as use as one needs.
This is a nice and free sunrise and sunset times API: http://sunrise-sunset.org/api
PHP has built in functions to calculate sunrise/sunset:
http://php.net/manual/en/function.date-sunrise.php
http://php.net/manual/en/function.date-sunset.php
Weather underground has this:
wunderground astronomy feature
Keys are free and they have a pretty generous policy for volume. Been using their weather actuals and forecast json forecast for about year, couldn't be happier.
EarthTools comes up first on google here at webservices sunrise sunset
The NASA one is cool, but the US Naval Observatory has one (below) that could actually pass for an API. If you want to make it useful beyond its intended purpose:
inspect the http headers to find out what parameters are being sent
parse the hell out of the response
It was a fun exercise. You should be able to send a location (long/lat or City/State) along with a year to obtain a list of sunrise and sunset times for an entire year (and other data as well).
http://aa.usno.navy.mil/data/docs/RS_OneYear.php
Go to this website > https://www.esrl.noaa.gov/gmd/grad/solcalc/
1. Set your location
Select your location. You can zoom in to your location and move the pin manually.
2. Verify your Location and Date
Scroll down to the 'Location' under the map and verify your location.
The date is automatically taken, if not set it manually.
3. Get the details
Click the button 'Create Sunrise/Sunset Tables for the Year'.
4. Output in a Table
New window opens and all the details are displayed as table.
Thanks to #noctonura for the link.
Let's go to http://www.earthtools.org/webservices.htm
It's free web service that provides Timezone and Sun times from Latitude/Longitude location.
There is a way to calculate the sunrise/sunset without the need of an API. Its mostly based on location. Sorry I dont have much more info.
Home page
Query url
Url syntax:
http://sunpath.azurewebsites.net/api/values/LAT/LON/ALT/TIMEZONE
You must replace LAT, LON, ALT and TIMEZONE with your data
.
JSON result:
{"zenith":55.365660255995422,"azimuth180":25.434155784212443,"azimuth":205.43415578421244,"incidence":55.365660255995422,"suntransit":12.423540739046871,"sunrise":6.9577562375305817,"sunset":17.899687249200021,"time":"2016-02-23T13:49:31.3816733Z"}
Or you can access online version of SPA.c algorithm:
Online query for SPA algorithm
Output is not in JSON format, but you can specify multiple times and get multiple results:
Date,Time,Top. azimuth angle (westward from S),Topocentric sun declination,Topocentric sun right ascension,Top. elevation angle (uncorrected)
2/23/2016,0:00:00,168.224314,-10.130760,335.659091,-57.643946
2/23/2016,1:00:00,-164.161551,-10.115560,335.699290,-57.227919
2/23/2016,2:00:00,-140.171655,-10.100376,335.739465,-51.963801
2/23/2016,3:00:00,-122.026618,-10.085209,335.779585,-43.529014
2/23/2016,4:00:00,-108.202194,-10.070054,335.819621,-33.425695
2/23/2016,5:00:00,-96.857772,-10.054907,335.859549,-22.544581
2/23/2016,6:00:00,-86.694509,-10.039764,335.899355,-11.406096
2/23/2016,7:00:00,-76.801678,-10.024618,335.939030,-0.376624
2/23/2016,8:00:00,-66.440121,-10.009464,335.978575,10.203398
2/23/2016,9:00:00,-54.907983,-9.994297,336.017999,19.930206