Facebook application error- Access Token - php

I have made new Facebook application, and when I am trying to allow "post to profile", I am getting this error:
Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /home/mimota/public_html/gamingapp.com/test/src/base_facebook.php on line 1024
Thats part of the base_facebook.php file:
http://codeviewer.org/view/code:2263
I have marked there where is line 1024
I will really appriciate if some one could figure out whats wrong here, because I have no clue..
Thanks.

Use a URL of the following format to log into facebook:
https://graph.facebook.com/oauth/authorize?client_id=288229791195831&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup&scope=publish_stream,user_photos,read_stream,email
They will give you a token back which you will use when you send requests:
For example to see get the main photo URL use:
https://graph.facebook.com/me/picture&access_token=THE_TOKEN_YOU_GOT_BACK
To post to wall replace /me/picture with whatever you need to post (sth like /me/wall)

Related

LinkedIn API Returns "Member does not have permission to get companies as admin"

I am using PHP SDK for linkedIn https://github.com/zoonman/linkedin-api-php-client , the login process is fine and I am able to fetch basic profile for users. But when I fetch the list of pages that user is admin of , it throws fatal error.
Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: GET https://api.linkedin.com/v1/companies?is-company-admin=true resulted in a 403 Forbidden response: { "errorCode": 0, "message": "Member does not have permission to get companies as admin."
here is the code.
use LinkedIn\Client;
use LinkedIn\AccessToken;
$linkedClient = new Client('ID','SECRET');
$linkedInAccessToken = new AccessToken($_SESSION["linkedinToken"]);
$linkedClient->setAccessToken($linkedInAccessToken);
$companies = $linkedClient->get('companies',array('is-company-admin' =>
"true"));
var_dump($companies);
Two points to notify.
1) The linkedin user is actually an admin of two company pages.
2) Following permissions are given from linkedin App.
r_basicprofile, r_emailaddress, rw_company_admin, w_share
I have spent hours searching for solution but the documentation is too vague. Any help will be greatly appreciated. Thank you !
Update: I solved the issue by passing $scopes array in getLoginURL() function. Although all these scopes are still ticked mark in application settings.

OAuthException: An unexpected error has occurred - after changing app namespace

we had a working facebook app with an own action that has been reviewed and been approved by facebook. Everything worked fine.
After changing the namespace and the title of the app, we now get an an error when sending the action via php sdk, althought all the action is still marked as approved and live.
$response = $facebook->api(
'me/myapp:create',
'POST', array('custom_object' => "http://www.myapp.com/metatags.php") );
This is the error we receive:
OAuthException: An unexpected error has occurred. Please retry your request later.
We've' already checked if the access token is vaild, it is!
Is it possible that facebook needs to re-approve custom actions after changing the namespace? Or does it need some time until it works again?
I dealt with this today, however my experience was in JavaScript, so I don't have relevant code to provide, you should be able to apply the same theory!
It seems that the error only happens once per access request - if you try to post again immediately after, it will usually be accepted by facebook with no error. Since the error code returned for unknown error is always the same, you can simply catch the error code from the response object and run the function again if it matches.

Dropbox REST API thumbnails call

I'm writing a script, which fetches files from dropbox using it's REST API.
$this->oauth = new OAuth($consumer_key,$consumer_secret,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
$url = "https://api.dropbox.com/1/metadata/dropbox/";
$this->oauth->fetch($url);
Calls like these are working, so I get the authentication right. However the I can't get the thumbnails call working.
I have links like https://api-content.dropbox.com/1/thumbnails/dropbox/contact-support.jpg
That's an existing file, just fetched by the call above (which lists my files). My Dropbox app is in "full dropbox" mode, so "dropbox" as root should be OK too. I'm getting
"Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 403, expected HTTP/1.1 20X or a redirect)'..." errors constantly.
Any help would be appreciated, I'm starting to get frustrated by this.
Thanks a lot!

Freelancer API snowtigerlib Wrapper Class for PHP didn't work

I used snowtigerlib freelancer api, it is a php wrapper class. I downloaded the full code from this link
Then I setup SnowTigerLib_Config.inc file with my key and secret. Then I did the following step:
First it went to the following url.
Then I logged in to sandbox with my username and password.
Next step, it went the following url.
Here Authenticate API Access was authorized.
After Authorizing API access it went the following url
Here it shows that it is authorized and the automatically redirect into my callback url with following error:
ERROR
Notice: Undefined index: token in ..........\callback.php on line 4
HTTP Error: http_code:401 in ...............\SnowTigerLib.php on line 455
Details: http://api.sandbox.freelancer.com/RequestAccessToken/requestAccessToken.xml?oauth_consumer_key=7484ba1fdfa9138ec77ead0c881966ad43f194ba&oauth_nonce=5a9b4e19b1fcd551e416d8e1fa86ab50&oauth_signature=LKRcVWNRdE%2BIzAzem2svR%2F0OiG8%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1356949656&oauth_verifier=4a24c84d5b49465a51ca990e2114945894896ed6&oauth_version=1.0
Please give me reply if anybody knows this issue.

Using Facebook Graph API + PHP SDK to get User's About data

Using the Facebook Graph API and the PHP SDK, I know that I can get the user interests with
$facebook->api("/me/interests")
However, assuming that I have the permission to, how can I get the user's About data?
$facebook->api("/me/about")
//gives error:
Fatal error: Uncaught OAuthException: Unknown path components: /about thrown in
[...]/base_facebook.php on line 1028
How can I get the logged in user's Facebook About data? Thanks.
EDIT: Here's a picture of the app permissions, as well as the code used to request the permissions.
$login_url = $facebook->getLoginUrl(array( 'scope' => 'email, publish_stream,
user_about_me, user_interests, user_education_history'));
Depends what 'about' information you want? You can specify individual fields but there is no overall about command to get all about information. Just go
$info = $facebook->api('/me?fields=id,email,work');
You can get a full list of what you can request plus further commands from http://developers.facebook.com/docs/reference/api/user/
Edit, if you are wanting the bio just add ',bio' to the fields
That kind of errors Unknown path components: /xxx usually occur when you are not properly logged in your developer account.
It may sound obvious, But I had similar problems until habituate to check/change accounts before work. {>_<}
I think this should be :
$facebook->api("/me/bio") ;
EDIT:
Just Use this:
$facebook->api("/me") ;
You can get all user information from this . Just parse the array for what you required . It outputs all the user related information
Some attributes like users phone,address are specifically and intentionally not available via the API, for spam prevention reasons . Facebook does not allow them to take through api
Try with this :)

Categories