How can I get comments when I have facebook post id - javascript

I want to fetch all comments of a post on facebook (my post and my friends post) using my access token.
I already have a post id, but when I call FB.api('/{post_id}/comments?access_token=xxxx), it returns error code 100 with the description:
Unsupported get request. Object with ID
'988927087866664_1344444165648286' does not exist, cannot be loaded
due to missing permissions, or does not support this operation. Please
read the Graph API documentation at
https://developers.facebook.com/docs/graph-api
Facebook also approved publish_actions permission for my website.
Thank you for your help

Related

Facebook API - POST a comment on a private groups post

I have successfully retrieved an post made on an private group and the comments made on this post. I want also to make the users on my app to be able to reply to comments on that post but cant get my head around this problem.
This is the API URL to GET all the comments on an post ID.
1338804626636796_1351943298656262/comments
When i try to do a POST call to this URL i get as a result:
{ "error": {
"message": "(#3) Publishing comments through the API is only available for page access tokens",
"type": "OAuthException",
"code": 3,
"fbtrace_id": "AM6a-he8gLoFA8SDVHjfDYO"
}
}
As far as i understand Page Access Token is used to manage Pages... Im working with Groups not Pages, and when i try to create a Page Access Token my Group that i want to manage wont show up ofcourse.
I then follow this guide:
Get a page Access Token API Docs
It asks for a PAGE ID, i have group ID but i try it anyways and get this as a response:
code: 100 fbtrace_id: "AnzTkEAsbp8s-Z__QawDBYX" message: "(#100) Tried accessing nonexisting field (access_token) on node type (Group)" type: "OAuthException"

Javascript Facebook SDK Add/Delete comment on Users feed. Access Token

I have a web app running on a local server that I can log into Facebook through.
I have been trying to add or delete comments from Posts are made by me and on my timeline.
When I try to execute the FB.api() call I get a failed response saying that I need a Page Access Token. The thing is, I've been looking around a lot and have seen nowhere a mention of a Page Access Token for a specific Persons profile.
Through experimenting I've been able to:
Get a Page Access Token for a non-profile Page that I own
Add/Delete Comments/Posts on that non-profile page
Add/Delete Posts made by the app on my profile
Display all Posts/Comments on my profile
What I want to do:
Be able to delete/add comments on Posts on MY profile
What I've tried:
GET request for {my-id}?field=access_token. I figured that if it worked for a non-profile page, it would work for my profile. It didn't work.
A lot of googling
My Assumptions:
I need a Page Access Token for my own profile if I want to add/delete things that were not made by the app
A Page Acess Token for a profile exists.
Below is an example of a FB.api call that would return a response saying:
"Publishing comments through the API is only available for page access tokens"
FB.api(`${comment_id}`, 'DELETE', function(response) {
console.log(response);
});
I really just need someone to give me some concrete answers.

Is there any way to delete photos with the Instagram API?

I tried doing a DELETE request to /media/{id} in the API console on their website, after authenticating with my own account and finding a photo id, but it said 405 METHOD NOT ALLOWED. Plus there are obviously built in requests for deleting comments, likes, etc.
Is there a workaround for this, or is it hopeless?
There is no API endpoint for delete media and there is not plan to add in near future
Reference : https://developers.facebook.com/docs/instagram-api/reference/ig-user/media#updating
Thanks

Get user name with Youtube Data API 3.0

Hi I'm trying to get the youtube user name and the thumbnail with a youtube app. I´m using the v3.0 and the javascript library.
I'm following this example and docs:
https://developers.google.com/youtube/v3/code_samples/javascript
https://developers.google.com/api-client-library/javascript/reference/referencedocs
I don't have problems with the autentication but I don't know how to get de user name and image.
Somebody knows?
You can call channels->list with "part=id & mine=true"
GET https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&key={YOUR_API_KEY}
Id is the channel's ID.
You can get the channel's title from response under snippet.title. This is what you need as usernames are not useful anymore.
From snippet.thumbnails.(key), you can pick the default, medium or high resolution thumbnail, and get it's width, height and URL.
This is what you are looking for to greet, but if you want to go deeper you can check if that account is linked with Google+ and use googleplususerid to retrieve more information via Google+ API.
https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token = [YOUR TOKEN]
YOU MUST get Oauth code and exchange it for Access Token, to :( complex to give you full answer HERE
Here's how I had to modify my requests to make it work with authentication (otherwise I kept getting a "dailyLimitExceededUnreg" error in the response):
Don't include the "key={YOUR_API_KEY}" in the URL.
Instead, add a HTTP header "Authorization: Bearer {ACCESS_TOKEN}"

How to get twitter oAuth token of a logged in user

I'm trying to set up a javascript function to post a status to a twitter account using POST statuses/update, details here: https://dev.twitter.com/docs/api/1/post/statuses/update. The goal is a Twitter post similar to the open graph actions on Facebook.
I'm using jQuery ajax to make the post request, here's what I have so far:
$.ajax
({
type: "POST",
url: "https://api.twitter.com/1/statuses/update.json",
headers: jsonData,
data: {},
dataType: "jsonp",
success: function( data )
{
}
});
I believe that I need to generate a header something like this for security:
Authorization: OAuth oauth_consumer_key=consumerKey, oauth_nonce=nonce,
oauth_signature=signature, oauth_signature_method="HMAC-SHA1",
oauth_timestamp=timestamp, oauth_token=userToken, oauth_version="1.0"
I have the consumer key for my app, I can generate a nonce, I'm generating the signature and timestamp using the methods from this question Twitter OAuth authentication in javascript. The only thing I have left is th oauth_token, which I believe is the token of the user whose feed I wish to post to. Please correct me if I'm wrong about that.
The problem is, I have absolutely no idea how to get this token from the user in order to post to their feed. I've spent the last 2 hours running around in circles through Twitter's oAuth documention without finding anything that looked useful; everything I've found was either flowcharts with no code examples or predicated on my code already having the user's oAuth token.
My question is this: how can I get the logged in user's oAuth token using javascript?
If that is not possible, I have another page where I am currently storing the user's twitter id in the database with their permission, getting their token and databasing it in PHP would also be satisfactory, assuming it doesn't change very frequently.
In order to obtain the oauth_token you need to follow the authentication process. Your application needs to be authorized to act on the behalf of the user.
I would recomend to take some time first and learn how OAuth exactly works (there is a lot of information available) and then implement it in your app. (http://hueniverse.com/oauth/)
You could also benefit from a library which will make your life easier. (in your case, look at: https://dev.twitter.com/docs/twitter-libraries#php).
Hope this has been useful.
Here is example for get twitter oauth token and post tweet in twitter .
Code sample is in php .
http://www.phpgang.com/how-to-post-tweet-on-twitter-with-php_414.html
1) to obtain the oauth token you need to follow the authentication process.
2) and your application needs to be authorized to act on the behalf of the user.
you can also see this twitter example for better understanding how it works
In this use can see the process of authorized user and post and get json result.
https://dev.twitter.com/rest/tools/console
I hope this will help you.
thanks

Categories

Resources