How to share post in Facebook using PHP? - php

I have 5 divs in my program and in each div, it contains different content and share on FB button. Now when I click on this button, I need to share that particular content on FB. How can I do that?

There are 2 ways. Below links may help you. I am using code from this article.
1) Using javascript:
http://thinkdiff.net/facebook/new-javascript-sdk-oauth-2-0-based-fbconnect-tutorial/
2) Graph API
http://thinkdiff.net/facebook/php-sdk-3-0-graph-api-base-facebook-connect-tutorial/

Try this
<?php
$title=urlencode('Dressfinity');
$url=urlencode('http://www.facebook.com/pages/Dressfinity-LLC/208406062583392 ');
$image=urlencode('http://livemarketnews.com/dressfinity/skin/frontend/default/default/images/logo.jpg');
?>
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');" target="_parent" href="javascript: void(0)">
Share our Facebook page!
</a>
For each div.

FB php SDK: https://developers.facebook.com/docs/reference/php/
This is full FB documentation for their PHP API.

Related

How to download QR code image of Google Chart API in php?

As we all know google provide as Free API named:developer.google.com
And I am looking a way to download the QR CODE image in any format(jpg, png).
I am creating dynamic Url which is pass to chl attribute of google API.
example:
<?php
$long_url = $row['urlinput']; //dynamic url is comming from database
echo '<div class="crop img-thumbnail img-responsive">
<img class=" crop" src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl='.$long_url.'&choe=UTF-8" title="'.$long_url.'" />
</div>';
?>
example output:
What I am trying to achieve is: download this QR CODE and save it into my computer.
I use: <a href="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl='.$long_url.'" download>download</a> But it seems it not working.
If there is any guidance or direction is provide then its my great honour.

Facebook share only certain div

So I have the following code for facebook share.
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>" class="post_share_facebook" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=220,width=600');return false;">
<i class="icon-facebook"></i>
</a>
Right now, when the share button is clicked, the whole snapshot of the page is shown on the share window.
On a php file where this share button is located, I have a specific div which I want to show on the Facebook share window instead of the whole snapshot of the page.
Does anyone know how I can do this?
Thanks!
Not sure if its possible that way, you can try <?php the_permalink(); ?>#your_div_id
Another alternate would be using open graph

How to cusomize facebook's sharer.php to sharer images on chats and Timeline

Below is the code used to share an image in facebook:
<div><a href="#"
onclick="
window.open(
'https://www.facebook.com/sharer/sharer.php?m2w&u=[[Link to share]]&mode=message',
'facebook-share-dialog',
'width=626,height=436');
return false;"><img src="send.png(the image clicking on which the sharer window will open)"></a></div>
the above code will open the facebook sharer window in private message mode.
If we remove the &mode=message after the link to share, the sharer window will say share on your timeline.
Can anyone please help me how to make the sharer window open saying 'share on a friends timeline' or 'share in a group' by default.
I'm not sure what you're asking for,
If we remove the &mode=message after the link to share, the sharer
window will say share on your timeline. Can anyone please help me how
to make the sharer window open saying 'share on a friends timeline' or
'share in a group' by default.
anyways if you want to show the option "Share on a friend's timeline" to be shown by default add &mode=friend to end of share dialog and for group use &mode=group
<a id="share" href="#" data-share="https://www.facebook.com/sharer/sharer.php?m2w&u=http://flatuicolors.com/&mode=group" class="groupBtn">Share in Group</a>
<a id="share" href="#" data-share="https://www.facebook.com/sharer/sharer.php?m2w&u=http://flatuicolors.com/&mode=friend" class="friendBtn">Share on Friend's Timeline</a>
Here's an example http://jsfiddle.net/AdamAzad/Lm2sc/
In order to "Share" via private message add
&mode=message

How to display pdf files from database in Google Docs?

Here is my code.
<i class="text-warning">View </i>
It echos the file.pdf in the database, when I clicked the link I want to redirect in Google docs. the google docs said they cannot find the specified folder.
Can someone help me to view the files into Google Docs after i clicked the link?
Try rawurlencode() and do not forget about = here ?url=:
<a href="http://docs.google.com/viewer?url=<?php echo rawurlencode($file_row['floc']); ?>">
But your $file_row['floc'] does not contain an URL:
http://www.domain.com/uploads/4145_File_app-developer-guide-2.4.pdf
a path only:
uploads/4145_File_app-developer-guide-2.4.pdf
Try add a schema and a domain:
<a href="http://docs.google.com/viewer?url=http://domain.com/<?php echo rawurlencode($file_row['floc']); ?

Is it possible to use facebook social plunging comment box to comment on my profile picture

Can anyone tell me Is it possible to use facebook social plugin comment box to comment on a picture in my profile?
This is the code for facebook social plugin comment box
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="MY_URL" num_posts="2" width="500"></fb:comments>
I tried this by replaying MY_UR with url of a facebook image in my profile(which is taken from garph api with a given image id).
<?php
$det = $facebook->api('/IMAGE_ID');
$image_url = $det['link'];
?>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="<?php echo $image_url; ?>" num_posts="2" width="500"></fb:comments>
But it doesn't work. Is there a way to do this?
Note : I have the publish stream permission.
You need to point the fb:comments href to the page that's hosting the comments plugin. This is where users will click when they see stories in their newsfeed after one of their friends has commented on your photo.

Categories