YouTube Analytics API: Finding unique visitors on a channel - php

I'm using YouTube Analytics API to find authorize a YouTube channel using OAuth2 and then trying to find the unique viewers that the channel encountered. This is the URL that I'm sending a request to:
https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel==MINE&start-date=2000-06-01&end-date=2016-04-25&metrics=uniques&access_token=XXXX
I'm using the uniques metric in the above case. However, this is what is returned as response:
Array (
[error] => Array (
[errors] => Array (
[0] => Array (
[domain] =>
global [reason] =>
badRequest [message] =>
The query is not supported.
Check the documentation at
https://developers.google.com/youtube/analytics/v1/available_reports
for a list of supported queries.
)
)
[code] =>
400 [message] =>
The query is not supported. Check the documentation a
https://developers.google.com/youtube/analytics/v1/available_reports
for a list of supported queries.
)
)
What seems to be wrong here?

A 400 response code identifies a bad request. It indicates that a request was poorly formed or contained invalid data. For example, you will receive a 400 response code if you submit a request to the wrong URL or include an unsupported or nonexistent parameter in your request.
I also found the same issue here. The solution for his problem, is that you need to specify the dimension to use the unique queries.
Dimensions are common criteria that are used to aggregate data, such as the date on which the user activity occurred or the country where the users were located.
For more information check this page.

Related

Getting twitch channel feed forbidden

As per the API: https://github.com/justintv/Twitch-API/blob/master/v3_resources/channel_feed.md#get-feedchannelposts
I have tried using PHP and cUrl to get the latest channel feed comments. This is the URL I am polling:
https://api.twitch.tv/kraken/feed/:username/posts
Obviously with :username as my actual username. I am also passing:
"oauth_token" => "[MY OAUTH TOKEN]"
I know that this procedure normally works because I am using it to get normal info about the channel and followers info. Though trying it with the feed posts I get this message back (after JSON decoding it):
Array
(
[error] => Forbidden
[status] => 403
[message] => Channel feed is disabled
)
When I set up the authorization for the account using oauth I included the following scope for allows:
user_read user_blocks_edit user_blocks_read user_follows_edit channel_read channel_editor channel_commercial channel_stream channel_subscriptions user_subscriptions channel_check_subscription chat_login channel_feed_read channel_feed_edit
As far as I know that is everything so not sure why it's coming up as forbidden, and as I mentioned I am using other parts of the API so not sure whats wrong here... Any ideas or help is greatly appreciated :)
I am by no means an expert on twitch's API but I'll give it a shot. Looking through their github documentation it shows 3 ways of sending access token for authentication.
Is it possible you're sending the token in the HTTP body? It explicitly states that this won't work with GET and DELETE methods, which could be giving you an error when trying to GET channel feed posts. Hope this helps.
EDIT: Yousimply don't have channel feed enabled on your account. It's currently opt-in because it's in beta. See: http://help.twitch.tv/customer/portal/articles/2377877-how-to-use-channel-feed

Get all facebook group post using FB Graph API

I want to get all facebook group post using FB Graph API.
I searched , googled, seen documentation for graph api, asked to so many persons, all are saying it is possible
Also i'm providing link from stackoverflow which i referred and tried
How to get all posts of a group via facebook graph api
But as you can see the post is very much old (from 2013)
When i tried to send request using CURL, at that time i'm not getting any error not any data
When i tried below code
$publish = $facebook-api('https://graph.facebook.com/v2.3/'.$group_id.'/feed/?access_token='.$params['access_token']);
at least i'm getting something in response
Array
(
[og_object] => Array
(
[id] => 859455820800214
[type] => website
[updated_time] => 2015-06-04T12:18:15+0000
[url] => https://graph.facebook.com/v2.3/659988617465253/feed/
)
[share] => Array
(
[comment_count] => 0
[share_count] => 0
)
[id] => https://graph.facebook.com/v2.3/659988617465253/feed/
)
So i just wanted to know that is it really possible at this moment?
And one good thing is that when i'm trying it from Graph API Explorer, i'm getting the data properly.
So where i'm wrong ?
Any little help would be greatly accepted
Why don't you just use the Facebook PHP SDK?
https://developers.facebook.com/docs/reference/php/4.0.0
You can get the group's feed via /{group_id}/feed, as described at
https://developers.facebook.com/docs/graph-api/reference/v2.3/group/feed#read
Make sure your Access Token is of the right type and contains the right permissions.

Twitter account/verify_credentials returning 34 error code

I found a whole bunch of related questions here, but since Twitter had made a lot of changes in its API, most of them are outdated (+ nothing actually solved my problem).
So My website is a semi social network (with posts, likes comments etc). The user has the option to post to twitter and facebook through my site. Everything is working just fine, posts are finding their way to both FB and TW.
I'm using Twitter oauth php library, posting is done like so:
$response = $connection->post("statuses/update", array('status' => "Tweet"));
but when if I want to verify user's credentials like so:
$response = $connection->get("account/verify_credentials.json");
I get:
[0] => stdClass Object
(
[message] => Sorry, that page does not exist
[code] => 34
)
I don't think the problem is in the authentication process nor in the app settings, for I was able to post a tweet but got that same error, both using the same access token (and obviously the same app).
apparently you get this 34 error for a variety of cases, the documentations is so ambiguous about it.
So any troubleshooting techniques are appreciated.
Just use
$response = $connection->get("account/verify_credentials"); // Remove the .json

Facebook Graph API Location Search Type

Hi and thank you in advance,
I am currently trying to send a search request to Facebook Graph Api in PHP, and each time i send a request to the API it returns an empty array.
Sending my request to the Graph Api using the exemple on the developer page of facebook located here
My parameters are the following.
Param
(
[access_token] => "this is a valide access token that i removed to posted in the forum.",
[type] => location,
[center] => 45.33,36.210,
[distance] => 2000
)
and the path of the request is the following : https://graph.facebook.com/search
with the Get method.
But my result is constantly the same, its an empty array.
Is this feature broken, not in service or am i sending the lat long in the wrong format.
Facebook places restrictions on retrieving posts that specify locations. You can only return results for your query if:
you or a friend authored the post
you or a friend were tagged in the post.
See here for more details: https://developers.facebook.com/docs/reference/fql/location_post/

Facebook: Get user's friends' time-zones

I would like my canvas application to obtain time-zones of my user's friends.
I tried doing it with the Graph API but all I can get is their names, locales and a few more (even when using the access_token).
When using FQL the timezone field is always empty.
Is there a way to achieve this?
If so, could you please point me in the right direction?
Cheers
I guess this is not possible, only the following fields were retrieved when calling $this->facebook->api("/friend_ID");:
Array
(
[id] =>
[name] =>
[first_name] =>
[last_name] =>
[link] =>
[gender] =>
[locale] =>
[updated_time] =>
)
Now in the documentation, the above fields are the fields marked Publicly available, in time the timezone field is Available to everyone on Facebook which sounds like the same but apparently it's not, anyway I've found this interesting article for a moderator on the facebook forums (not a developer!!)
Also tried the old rest lib, first get a list of your friends from the console and then add your ID and put them in the test console of the users.getinfo method, UIDs looks like your_id,friend_id,friend_id,friend_id,friend_id and fields timezone you'll only get your timezone.

Categories