Using PHP 5.2.11 and the new facebook graph code...
If I call
$facebook->api("/me");
I get a proper response:
array
'id' => string '10700210' (length=8)
'name' => string 'Brandon Renfrow' (length=19)
'first_name' => string 'Brandon' (length=7)
'middle_name' => string '✫' (length=3)
'last_name' => string 'Renfrow' (length=7)
'link' => string 'http://www.facebook.com/brenfrow' (length=32)
'about' => string 'Spiritual birthday: 1/22/2005' (length=29)
...
...
But if I call
$facebook->api("/me/picture");
I always get a response of:
null
Does anyone know why this is?
Well I guess the best answer I've found is to call http://graph.facebook.com/USER_ID?fields=picture to get the picture URL. Its to bad they don't document things like this on their API especially when its obvious this is broken for so many people.
As an addition to betaman's answer, you can pass the parameters in a separate array like so:
$aResponse = $oFacebook->api('/me', array(
'fields' => 'picture',
'type' => 'large'
));
You may not even need to do an API call... use this on your frontend:
<img src="//graph.facebook.com/USER_ID/picture?type=square" />
Read more here: http://developers.facebook.com/docs/reference/api/#pictures
There is an even simpler way, using the provided facebook api, just call:
$facebook->api("/me?fields=picture");
This will make your code simpler and more elegant.
While using $facebook->api("/me?fields=picture"); does work, you won't be able to pass parameters such as width or type. Instead try the following:
$facebook->api('/me/picture?redirect=false');
This worked for me and will also allow you to pass parameters.
I just went to my "/me/picture" in the browser and it redirected me to a static image on one of Facebook's CDN servers. Perhaps the redirect is throwing a wrench in your api call.
Related
I'm trying to use the Facebook share dialog with the redirect uri. However, because my URL has link parameters in it, it doesn't want to work properly and the link that actually gets shared on Facebook is missing params etc. How can I remedy this?
Link example: https://www.facebook.com/dialog/share?app_id=APPID&display=popup&href= LINK COM/INDEX.PHP?PARAM=1&PARAM2=2&redirect_uri= LINK COM/INDEX.PHP?PARAM=1&PARAM2=2
I saw something about htmlspecialchars() but it didn't work for me, or maybe I just don't know how to use it properly.
Here's the easy bullet-proof way to build this URL:
$share_url = 'https://www.facebook.com/dialog/share?'.http_build_query(
array(
'app_id' => 'APPID',
'display' => 'popup',
'href' => 'http://example.com/INDEX.PHP?PARAM=1&PARAM2=2',
'redirect_uri' => 'http://example.com/INDEX.PHP?PARAM=1&PARAM2=2',
),
null,
'&'
);
Due to the May 2015 updates my application cannot use the login with LinkedIn option, this is the snippet I'm using:
$linkedinService->request('/people/~:(first-name,last-name,email-address)?format=json')
When I use the web console it returns the correct data, but if I dump the result from the app I get this:
array (size=5)
'errorCode' => int 0
'message' => string 'Unknown field {~%3A%28first-name%2Clast-name%2Cemail-address%29} in resource {Root}' (length=83)
'requestId' => string 'asdfghjk' (length=10)
'status' => int 400
'timestamp' => int 1435742730817
Update:
The exact curl request is: (with access token)
https://api.linkedin.com/v1//people/~%3A%28first-name%2Clast-name%2Cemail-address%29?format=json&oauth2_access_token=
If I paste that in the web console I get
Could not find person based on: ~%3A%28first-name%2Clast-name%2Cemail-address%29
But if I urldecode it first and paste it in it returns the correct data
Hi I got the same problem. I find out that it is URL Problem. In request uri don't use // double slash like you did in your example m/v1//people/.
I know its been you have posted here but someone else can get benefit of it.
The video uploaded via the new API used the "video name" but the privacy setting doesn't change (I need it to be disabled from vimeo.com but can be embedded from other sites).
$video_data = $vimeo->request($uri, array(
'name' => 'video name',
'privacy' => array(
'view' => 'disabled',
'embed' => 'anywhere'
)
), 'PATCH');
Does anyone know why it's not working?
I find an alternative way to do this by changing the global defaul settings: https://vimeo.com/settings/videos
Many thanks
The correct request is:
// The docs refer to the following as "privacy.view"
array('privacy' => array('view' => 'disable'));
From https://github.com/vimeo/vimeo.php:
NOTE: How to use the PHP library with the Vimeo Docs.
The API docs often uses dot notation to represent a hierarchy of data (eg. privacy.view). Because this library sends all data using JSON, you must use nested associative arrays, not dot notation.
The value is "disable" not "disabled". You can see our docs here
My problem is, while i post score using facebook php sdk it alwasys give error as Unsupported method, post.
Here is the code I use:
$app_AccessToken = $obj_facebook->getAccessToken();
$obj_facebook->api('/100003470602309/scores/', 'post ', array('access_token' => $app_AccessToken, 'score' => '154125'));
use some thing like
$obj_facebook->api('/me/scores', 'POST', array( 'score' => 100, 'access_token' => $obj_facebook->getAppId().'|'.$obj_facebook->getApiSecret() ));
try this :p may be it will help
It could be due to access token. Make sure you have an app access token.
i'm using this code to post to my application wall
$attachment = array('message' => 'xxxxxxxxxxxxxxxx...',
'name' => 'xxxxxxxxxxxxxxxxxxx',
'caption' => 'xxxxxxxxxxxxxxxxxx',
'link' => 'xxxxxxxxxxxxxxxxxx',
'description' => 'xxxxxxxxxxxxxxxxxx',
'picture' => 'xxxxxxxxxxxxxxxxxx',
'actions' => array(array('name' => 'Download!',
'link' => 'xxxxxxxxxxxxxxxxxx'))
);
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
when i post to my application wall manually the post is appearing on the application users wall with the share action
but when i use the above code it only appear on the app wall with like and comment actions only.
why?
and how to add the share action to the actions array?
i didn't find any answer online, but i just found the solution to my problem by chance
i removed the action parameter from the attachment.
but if there is a link parameter in the attachment the share action won't appear so you will have to give up the link parameter.
the proper names for the action link is:
array( array('text' => 'Download!', 'href' => 'xxxxxxxxxxxxxxx'));
Keep in mind that you can't use action links in the graph api (yet). so this functionality is limited to the REST api.
Let me know if this helps
http://facebookanswers.co.uk/?p=270
This article explains it. The key is this:
'actions' => array('name'=>'Sweet FA','link'=>'http://www.facebookanswers.co.uk'),
This is fine for adding one action. However, I'm not sure how to add two.
Hi the solution is here
instead of
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
use
$result = $facebook->api('/2222222222222/links/','post',$attachment);
i'm still facing one little problem with the picture not showing after this change, if i come to a solution to it I'll come back here and post it.