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,
'&'
);
Related
I'm using the following code to upload photos to Facebook fan page as the page (not as a user):
$ret_obj = $facebook->api ( '/'.$fanpageid.'/photos' , 'POST' , array(
'source' => '#' . $filename,
'message' => $message,
'link'=>$link,
'access_token'=>$accesstoken
));
This code was working until June 11th, 12 AM. Did Facebook change the way it works?
I have the fan page access token, and everything was working fine. How do I make it work?
found the solution myself, an alternative way is working instead of
'source' => '#' . $filename,
using
'url' => $fullpathfilename,
is working, weird that facebook doesnt document those important changes.
I hope you will be able to help me.
I'm developing an app, and I'm willing to post an activity (that appears on user timeline in recent activity) everytime the user use my application.
Although, for the moment, I have this code below, and it only posts a normal link :
if($can_post){
$facebook->api('/'.$uid.'/feed', 'post', array(
'message' => '',
'name' => 'Name',
'caption' => 'Caption',
'description' => 'SDesc',
'picture' => 'picture url',
'link' => 'link',
'actions' => array(array('name' => 'catch phrase',
'link' => 'http://link'))
));
Check out this guide on posting "stories" to the user's timeline using the Open Graph API, so maybe it's this functionality that you need. The example they give is just a like, but it can be easily modified.
Be aware that Facebook will have to approve you app again if you want to use stories (see end of page on link above).
It's also worth noting that Facebook have also defined a wide range of predefined "Actions" to help in the process, so it's a good idea to check to see if your app falls into one of these categories.
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.
I am building a Facebook app with voting included. With it I want to send a message to the user's wall including some text and two or more links.
I also want to control the link text so that I can get links like "Yes" and "No".
The first thing I tried was posting regular -tags, but (no surprise) that didn't work. I have seen other apps do this though. Are there any special tags that allow links?
Thank you.
I'll assume that you're using the Graph API and already have publish a post working.
I think the properties property might be what you are looking for (it is left out of the new API reference but is described here). This allows links although they might not be formatted quite how you want. Example:
$data = array (
'name' => ...,
'link' => ...,
'properties' => array (
'Yes' => array (
'text' => 'Vote',
'href' => 'http://www.example.com?vote=yes'
),
'No' => array (
'text' => 'Vote',
'href' => 'http://www.example.com?vote=no'
)
),
); //And whatever other properties you want
$facebook->api('/uid/feed', 'POST', $data);
The properties will appear after beneath description in the post and come out like the following:
Yes: Vote
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.