Twitter API - Simple data required - Advice on how to get it - php

I require 2 bit of data from my twitter account to be dynamically requested.
(1) Followers (as of this month)
(2) Total followers
I have a couple of questions regarding how to get the data & if the data is available.
For (1), is this even available? or is this something I'd need to calculate?
For (2), so far I've been pointed in the direction of the Twitter API & oAuth. Now, to me - just get the total followers for my account - logging in via oAUth & using large class libraries (PHP) seems like total overkill.
How I can get the data I require?

twitter has buttons you can simply drop on your page. this will allow you to show the follower count as well as allow people to follow you directly form whatever page you put it on.
https://dev.twitter.com/web/follow-button

There is no way to get the data you want directly.
Twitter offers an API call which will tell you how many followers you have right now - https://dev.twitter.com/rest/reference/get/users/show
It does not provide historic data via the API - such as how many followers you had at a specific date.
You have two options.
Make that API call at the start of the month and save the result somewhere - then compare your current follower number.
Take a look at https://analytics.twitter.com/user/edent/home (substitute your own name for edent) - you'll see something like this for each month:
There's no API for that data, but you might be able to screen scrape the data you want out of it. Or just manually copy & paste.

Related

Retrieving Facebook Page Statuses with PHP

Having trawled the web for days, I cannot find an up-to-date, working method to retrieve a list of the latest statuses on a Facebook page.
On the status section of the Graph API, I am greeted with "This document refers to a feature that was removed after Graph API v2.3"
I can't get file_get_contents to work on Facebook pages as I'm presented with a Captcha
It's for competitor research, I only actually want:
Post date
Number of Likes/Share/Replies
I couldn't care less for the status content itself, just the metrics around it.
A JSON object would be great, but I'll take anything at this stage.
Anyone else managed to get this sort of data or know a way to use file_get_contents on Facebook pages?
Thanks.
A status is just a certain kind of post – so all you need to do is request the page’s feed (resp. posts) instead, and then check if their type is status.
I've just tried to access the post object to get like/favourite counts .etc and get "[message] => (#12) singular statuses API is deprecated for versions v2.4 and higher"
You need to use the “full” post id as you get it from the /feed or /posts endpoint – the combination of page-id, underscore, post-id. (At least that’s the current format, but someone from Facebook told me we should not rely on that, it might change at some point. Best if you really just use the full id, as the endpoint returns it.)
And since you are interested in overall number of likes only, not the individual likes, you could make a request like this,
{full_post_id}?fields=likes.summary(1).limit(0)
That requests the summary (contains total counts), and limits the number of individual likes returned to zero (so as not to request any unnecessary data.) It works the same for comments. But I think for shared posts there is no such counts, you will only get a list of posts (which might not be all, but only those you are allowed to see.)

How do I retrieve a list of the pages visited on a particular day using the Google Analytics API?

We use Google Analytics on our site to track page views, and I am interested in getting a list of which pages were viewed on a given day. I'm not looking for the number of times a page was viewed primarily, as I know that this information is available if we need it. Rather I want a list of all of the unique URLs visited on the site for a given day. Is there a way to do this?
TL;DR
You can query the landing page dimension and visitor metric to get that data. For more info here is Google Analtyics query explorer and dimensions/metrics reference
Slightly longer answer:
Here is the dimension you would want to use.
ga:landingPagePath
Here is the metric you would want to use.
ga:visitors
This will give a report of the urls for the date range you want and the amount of traffic it got. If you don't care about the actual traffic you can just remove that once the data is pulled.
Here is more info/examples about google's data api's for python
If you are familiar with using the API, selecting these two dimenions:
Page
Date
and any of the relevant page-level metrics (pageviews, unique pageviews, etc.) will product the desired report.
Try using this link to shared-report from GA Query Explorer, I believe those are the numbers you want.

Is there any way to get the number of FB users on a specific country?

I would like to know if is there any possible way to show the total number of users of a specific country in my webpage. As far as I found, you can not get it through API.
I'm guessing you really want the total number of users on facebook who have 'liked' or used facebooks oauth to connected with your site.
Do you use graph api in your site? I'm pretty sure you can query by country name--as long as the user's who have shared that info with you have provided it.
Check this out... http://developers.facebook.com/docs/reference/api/
And this: http://developers.facebook.com/docs/reference/api/insights/
From their site
Facebook Insights provides the ability to see geographic and
demographic data for people that have Liked a Page or installed an
app. Location data is based on the geographic location of each person
as determined by their browser IP address and is limited to the top 20
countries and cities. All other demographic information is aggregated
and non-personally identifiable.
Generic searches can be done like this:
https://graph.facebook.com/search?type=location&place=166793820034304
Where the place id is the id for whatever you want to search on.
https://graph.facebook.com/search?type=location&place=166793820034304
Disclamer: This method is not supported by Facebook. Use it at your own risk. I take no responsibility whatsoever.
Go to: https://www.facebook.com/ads/manage/adscreator/
Fill in the ad info with something random (eg. google.com as the url)
In the next part you'll notice a dynamic reach estimation that changes depending on the parameters you select, including country. Try changing the country and observe the network activity with for instance the developers tools of Google Chrome.
Call the ajax url that returns the json data with the proper parameters programatically, this should be easy to figure out in the previous step.
Collect and store the json data for your evil deeds.
???
PROFIT!
The actual ajax call and parameters change from time to time, which is why I didn't include them directly, but it should be easy enough to figure it all out. Also note that they are estimates, even if they come from Facebook, they don't count every single user every time an advertiser sets up an ad — it's the best estimate you can possibly get though.
This method as I mentioned is neither official nor supported by Facebook, but sites like socialbakers.com or checkfacebook.com have been using them for ages. (There, I revealed the secret)

PHP API - Friends by date

How to get the friends list by the date they added?
Or How long two users are friends. I have seen some questions like this. But they are old. I don't know whether facebook have added any options for this.
I want to use graph api - php
Facebook doesn't provide any way to retrieve such information.

I need to get the Direct Messages one by one using twitter api

What I am trying to do is a twitter bot for retweeting whatever I have in my DMbox.
So I need a few things.
I need to follow all the users who follow me. (I did that)
I need to read the DMs( I have to do)
Tweet the DM (I can do it i guess)
Delete the Read DMS(I dont think I wil be able to do it without help)
The problem with reading DMs are I am getting all the DMs at once. How can I tweet it one by one, I mean how I can take one DM from this Response I am getting for "$_GET['https://api.twitter.com/1/direct_messages.json']"
Now after retweeting all these DMs how can I delete all of them?
If you are using the GET direct_messages method provided by the REST API, you can use a combination of the since_id, max_id, and count to request one DM (count) older than (max_id) or more recent than (since_id) some known DM. https://dev.twitter.com/docs/api/1/get/direct_messages
Here is an example: https://api.twitter.com/1/direct_messages.json?count=1&since_id=1270520569
After you have grabbed the DM and thus, received it's id, you can grab your next DM using the above code and delete the current message using the POST direct_messages/destroy/:id method also available through the REST API. https://dev.twitter.com/docs/api/1/post/direct_messages/destroy/%3Aid
Here is an example of the delete method: https://api.twitter.com/1/direct_messages/destroy/1270520569.json
To get the first DM that you use to begin your process of retrieving messages, simply use the GET direct_messages with a count of 1 and move either backwards or forwards (max_id or since_id) depending on how Twitter orders the tweets. If they are not ordered by time, you'll simply have to explore in both directions.

Categories