Getting twitch channel feed forbidden - php

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

Related

Unsupported get request when trying to read ad_id with Facebook Graph API

I'm building a Facebook application that uses a webhook to read Facebook leads. The application is now working fine: every new lead in my campaigns are sent via the webhook to my script, with the needed information about the lead: ad_id, form_id, leadgen_id and so.
Now, I am trying to get some additional information with the Facebook Graph API based on the ad_id, form_id and leadgen_id and I'm having issues with this. I tried the Facebook Graph API in both PHP curl, and a direct HTTP GET call, and I'm having the same issue in both ways.
When I try to fetch the lead object using leadgen_id, it works fine, and I can get the name, email and phone that I need.
When I try to fetch the form object using form_id, it also works fine, and I manage to get the form name.
But when I try to fetch the ad object using the ad_id (since I need the name of the ad) it gives me the following error: "Unsupported get request. Object with ID '23848043174300142' does not exist, cannot be loaded due to missing permissions".
Currently I have the following permissions (advanced access): pages_read_engagement, pages_manage_ads, pages_manage_metadata, pages_show_list, leads_retrieval, public_profile, ads_management.
Is it an issue with the permissions or with my call?
I tried both PHP curl, and a direct HTTP GET call, and I'm having the same issue in both.
My HTTP GET call to retrieve the ad's name (based on ads_id) is the following:
https://graph.facebook.com/v11.0/ADS_ID?access_token=MY_LONG_TIME_APP_ACCESS_TOKEN
(when I'm replacing ads_id with leadgen_id or with form_id, it gives me the relevant object without any problem).
Thanks,
David
I am sorry if this comes up late, I just had a very similar issue and the solution was to go to the Business Manager then Business Settings > Integrations > Leads access and assign the user that we are using the token for to the corresponding brand.
Facebook explains it here under Note: https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving/
Hope this helps some people.

Missing elements in Feed data returned by Facebook Graph API

I am using the Graph API to retrieve Feed data from a number of public Facebook pages and a public Facebook group. The array of data returned by the API occasionally contains Posts with missing data which is visible when the Posts are viewed in Facebook.
I wonder if anyone can shed light on this, and explain whether it is just a glitch in the Graph API, or some sort of permissions issue?
The problem appears to occur with data from the public Facebook Group, and affects Posts which are of [type]=Status under certain conditions. A couple of examples:
Posts of [type]=Status where the user has included a link: In this scenario, the Post [message] is present, but the [link] and [picture] elements are missing. The data returned includes the following data - "[caption] => Attachment UnavailableThis attachment may have been removed or the person who shared it may not have permission to share it with you".
All the [comments] and [likes] data is present and correct.
Posts of [type]=Status where the user has posted a photo: In this scenario, the [message] and [picture] elements are missing, but the [comments] and [likes] data is present.
For Posts of [type]=Status with just a simple [message] (no photo or link) the Post data all seems to be returned correctly by the API. Posts of [type]=Link or [type]=Photo are also returned correctly. I don't seem to see any of these problems when retrieving data from the Facebook Pages.
I am using the Facebook PHP SDK to retrieve the data. Currently I am using SDK 4, but I experienced the same problem with the previous version of the PHP SDK. I am making a simple GET call, with an App Session constructed using my App ID and App Secret (no access token).
I'm guessing there is something subtle going on with permissions here (as indicated by the caption message for the first scenario above) but the Group is public, and the missing data can be viewed on the Group page by any Facebook user.
This question appears to be related but I have not been able to track down any information about my specific problems, so any suggestions gratefully received!

Youtube API Retrieving Channel ID after authentication

I am using Google Youtube API and YoutubeAnalytics API, I read on their documentation that you need a CHANNEL_ID inorder for you to grab the user's videos.
I can now successfully Google authenticate the user in my application, I just wanted to ask if how can I get their CHANNEL_ID after they authenticate.
I am using PHP, I've been searching over the net but can't seem to find any example how to do that.
Your help will be greatly appreciated!
Thanks! :)
Since you're using PHP, I'm assuming you're using the PHP-based gapi-client? Here's the call to make:
$listResponse = $youtube->channels->listChannels('id', array(
'mine' => 'true',
))
The 'id' part returns the ID of the channel, and by passing the parameter "mine" as true, you're telling the API to return the data for the authenticated user.
If you're using a different client or rolled your own, you can also just hit this endpoint (passing the oAuth access token you have in the header or as another parameter to the request):
GET https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&key={YOUR_API_KEY}

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 access token for offline_access - PHP

I'm trying to get the status from facebook users, who connect to my app with offline_access and read_stream permissions.
All the processes will use subscription to get notification about new feeds, and then take access to status of the user, who changed it.
The code for subscription works great, I get all info as it should be, but the problem starts with second part - every time I try to access user status via
$objFacebook->api('/'USER_ID'/statuses?access_token=TOKEN', 'get', $params);
I get the exception:
An access token is required to request this resource
I tried to set access_token which I got when connected to my website via facebook login, also tried to set the whole session in similar way as it is done here:
Array
(
[access_token] => ...
[base_domain] => ...
[expires] => 0
[secret] => ...
[session_key] => ...
[sig] => ...
[uid] => ...
)
but it didn't help. On the other side, when I copied my access_token generated via facebook developers (http://developers.facebook.com/docs/reference/api/user/) it works correctly, so it looks like my app generates an incorrect access token.
Do you have any idea where the problem can be?
To connect I use facebook-php-2.0 library.
You should upgrade to version 3 of the PHP SDK. We made some changes to the cookie format and other things you can read about here. Version 2 will stop working on September 1st, so you'll need to upgrade soon anyways. Once you've done that, things should work for you.
P.S. You probably will want to use the "/posts" connection rather than than the "/statuses" connection of the User object as it will also give you any posts the user made that include attachments. The "/statuses" connection will only return text-only posts the user made. We'll update the documentation to clarify that.

Categories