Has Facebook sharer.php changed to no longer accept detailed parameters?

前端 未结 5 934
醉话见心
醉话见心 2020-11-27 09:59

We have been opening a sharing popup (via window.open) with the URL like

https://www.facebook.com/sharer/sharer.php?s=100&p[title]=EXAMPLE&p[summary]         


        
5条回答
  •  心在旅途
    2020-11-27 10:39

    Your problem is caused by the lack of markers OpenGraph, as you say it is not possible that you implement for some reason.

    For you, the only solution is to use the PHP Facebook API.

    1. First you must create the application in your facebook account.
    2. When creating the application you will have two key data for your code:

      YOUR_APP_ID 
      YOUR_APP_SECRET
      
    3. Download the Facebook PHP SDK from here.

    4. You can start with this code for share content from your site:

       'YOUR_APP_ID',
          'secret' => 'YOUR_APP_SECRET',
          'allowSignedRequest' => false // optional but should be set to false for non-canvas apps
        );
      
        $facebook = new Facebook($config);
        $user_id = $facebook->getUser();
      ?>
      
        
        
      
        api('/me/feed', 'POST',
                                          array(
                                            'link' => 'www.example.com',
                                            'message' => 'Posting with the PHP SDK!'
                                       ));
              echo '
      Post ID: ' . $ret_obj['id'] . '
      '; // Give the user a logout link echo '
      logout'; } catch(FacebookApiException $e) { // If the user is logged out, you can have a // user ID even though the access token is invalid. // In this case, we'll get an exception, so we'll // just ask the user to login again here. $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' )); echo 'Please login.'; error_log($e->getType()); error_log($e->getMessage()); } } else { // No user, so print a link for the user to login // To post to a user's wall, we need publish_stream permission // We'll use the current URL as the redirect_uri, so we don't // need to specify it here. $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) ); echo 'Please login.'; } ?>

    You can find more examples in the Facebook Developers site:

    https://developers.facebook.com/docs/reference/php

提交回复
热议问题