php - Sharing custom data to facebook/linkedin -


i want user able share(post) data facebook/linkedin page. there facebook sharer link supposed deprecated now? tried this doesn't work entirely. there share button need link html without additional mess.

people seem sharrre think there should easier solution.

i noticed there 2 different aspects when trying share data:

  • pre create text put share textbox (this works twitter sharrre instance, not fb/linkedin… )
  • use url put sharer , sharer automatically detects properties such title,image,description (text stays blank , it's user write something)

what current best , fastest way share info page facebook and/or linkedin? (without using generated share buttons)

##### edit: figured out linkedin. can use

https://www.linkedin.com/cws/share?url=your_url?your_parameter=param_value 

and able show param onward php $_get instance , put in

<meta property="og:description" content="this param <?php echo $_get['your_parameter'] ?>" 

this way can show customised information sharing.

for facebook there issue passing params-they not read. link formed correctly when redirected facebook sharer url gets encoded differently. ideas?

http://www.facebook.com/sharer.php?u=your_url?your_parameter=param_value 

i figured out: if want pass custom data share facebook , linkedin need:

  • create own server (in case php) custom data looks this:

    <?php  if(isset($_get['your_parameter']))     $par = $_get['your_parameter'];  ?> <meta charset="utf-8"> <title>site title</title> <meta property="og:title" content="site title" /> <meta property="og:type" content="website" /> <meta property="og:url" content="your_url?your_parameter=<?php echo $par ?>" /> <meta property="og:image" content="your_img_url_can_use_parameters_also" /> <meta property="og:description" content="you can use parameter shown description when sharing facebook this: parameter! <?php if($par) echo $par; ?>!" /> 

(put in head tag of course; can leave body empty… )

  • use link in html when want share fb/linkedin (this example angularjs, pass variable instance in php echo well)

    <a ng-href="http://www.facebook.com/sharer.php?u=your_url?your_param={{param_value}}" target="_blank">         <div class="text">share via facebook</div> </a> 

so sum up:

use

http://www.facebook.com/sharer.php?u=your_url?your_param=param_value 

to share facebook (this sharer supposed deprecated works)

use

https://www.linkedin.com/cws/share?url=your_url?your_parameter=param_value 

to share linkedin.

but beware: facebook takes parameters

<meta property="og:url" 

where linkedin takes them url customised server resides on.

you can use facebook debugger tool see customised server returns.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -