Facebook Graph API. How to get comment from post - php

Hi i have this to get comment from post it works is there is a years
$json = file_get_contents("http://graph.facebook.com/730350233684840/comments?limit=2500");
echo $json;
but now i have this error in facebook
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
how i can get all comment from post ?
i have using your code #luschn
my request with true APP ID and App Secret
https://graph.facebook.com/730350233684840/comments?limit=2500&access_token=[APPIS|APPSECRT]
i have this
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException",
"code": 190
}
}
i use chrome to look this error
--
English is not my native language, sorry for any mistakes.

For example:
$json = file_get_contents("http://graph.facebook.com/730350233684840/comments?limit=2500&access_token=[your-access-token]");
The most basic Access Token is an App Access Token, you can create one like this:
$appAccesstoken = $appId . '|' . $appSecret;
Depending on the resource, you may need a User or Page Token though. For that, you will have to authorize the User and it gets a lot more complicated.
More information about Access Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/

you have to change the position access token and limit
https://graph.facebook.com/167416583311544_730350233684840/comments?access_token=appId|appSecret&limit=2500

Related

Facebook Graph-api, premissions for Shares count (Invalid OAuth access token signature)

I am far from the programming and PHP, but got the challenge to get the Fb share count for the website :)
I'm trying to get the proper App Access Token and send the request to Fb
according to this article.
The request should be like this:
https://graph.facebook.com/?ids=http://www.myurl.com/my-page&access_token=myappid|myappsecret
And I getting this error.
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "FfZKAkCyad1"
}
}
I am going to use it in PHP roughly like this:
function facebook_count($url)
{
$results = #file_get_contents('http://graph.facebook.com/' . $url .'&access_token=myappid|myappsecret');
if ($results) {
$like_array = json_decode($results, true);
if (!empty($like_array['shares']))
return ($like_array['shares']);
}
return 0;
}
My guess, I checked wrong Permissions (scopes) for my App token. Did not found an answer in FB dev page. Checked this for now:
user_likes, read_insights, read_audience_network_insights, public_profile
What Scope do I need to check, if I need only the shares count by the link?
Or in what else could be the problem?
You need to use an App Access Token... So the actual permissions (referring to User Access Tokens!) are irrelevant.
So, hopefully you are replacing myappid|myappsecret with your actual App Id and App Secret. If ynot, there's your error. Furthermore, I think in the file_get_contents call then ?id= part in the URL is missing.

How to remove duplicate Facebook Access Tokens?

I have 100 Active Facebook access tokens.
For each account I have more than one access token.
I want to keep only one token for each account and want to delete the others.
And i don't want to do this manually so please post a PHP script which check all the tokens and keep only one active token for each account.
In such a case the simplest way to validate an access token is to issue the following request
https://graph.facebook.com/me?fields=id&access_token=#accesstoken
If the provided access token is not valid or expired Facebook will just return an error message of some sort. Such as :
{
"error": {
"message": "Error validating access token: This may be because the user logged out or may be due to a system error.",
"type": "OAuthException",
"code": 190,
"error_subcode": 467
}
}
For a valid access token the result will somehow look like this
{
"id": "ID_VALUE"
}

FQL app access tokens

Note: App access tokens are being used here so there is no login or permissions required.
My app access token is valid according to the Facebook App access token debugger
My FQL request is correct according to the Graph API explorer (for FQL)
However when I attempt a FQL search using my app access token:
$fql_query_url = 'https://graph.facebook.com/'.'fql?q='.urlencode($fql_query) . '&access_token=' . urlencode($acctoken);
I get the response:
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}
}
The code I'm using literally worked two days ago but not it appears to be broken.
Does anyone know what is going on? I've looking into the app access token depreciation after 60 days but surely this would appear as an invalid token in the Facebook access token debugger. Also isn't the error message different if the app access token is depreciated.

LinkedIn API to post Share using php oauth class

The details:
I am using Manuel Lemos php oauth class and the login_with_linkedin.php script as reference.
I have successfully gone through the oauth process and retrieved the user's info using the API 'http://api.linkedin.com/v1/people/~'
I get an error when using the Post Shares API (http://api.linkedin.com/v1/people/~/shares)
Here is the relevent code from my last unsuccessful attempt;
// Scope settings
$client->scope = 'r_fullprofile r_emailaddress r_network rw_nus';
// Call to API (Post)
$success = $client->CallAPI(
'http://api.linkedin.com/v1/people/~/shares',
'POST', array(
"format"=>"json",
"comment"=> "Test"
), array('FailOnAccessError'=>true), $user);
Here is the error message:
Error: it was not possible to access the API call: it was returned an unexpected response status 401 Response: { "errorCode": 0, "message": "Unknown authentication scheme", "requestId": "8DWA0EBJTB", "status": 401, "timestamp": 1355774186502 }
Any help would be greatly appreciated. Thank you.
I posted the same issue on the class creator's forum as well.
He got back to me with an answer that worked.
The answer can be found here:
http://www.phpclasses.org/discuss/package/7700/thread/22/

php + facebook. geting access token returns: Error validating verification code

After a user is redirected to login dialog
$url = "https://graph.facebook.com/oauth/authorize?client_id=$appid&scope=&" .
"redirect_uri=$process_url";
where $process_uri is urlencoded url of form https://my.domain.com/process.php?param1=value1&param2=value2. After user returned to https://my.domain.com/process.php I do curl request to (have tried to use file_get_contents first):
$url = "https://graph.facebook.com/oauth/access_token?client_id=" .
"$appid&redirect_uri=$current_url&client_secret=$secret" .
"&code={$_REQUEST['code']}";
I'm getting { "error": { "message": "Error validating verification code.", "type": "OAuthException", "code": 100 } }.
After googling I realized that the main reason that may cause the problem is wrong redirect_uri in curl request. The question is: what should be redirect_uri in curl request? https://my.domain.com/? Or https://my.domain.com/process.php? Or https://my.domain.com/process.php?param1=value1&param2=value2?
Thank you in advance!
Remove the code parameter when you're submitting the current URL as the redirect_uri to the https://graph.facebook.com/oauth/access_token endpoint.

Categories