链接到facebook上的预填充状态

链接到facebook上的预填充状态,facebook,Facebook,Twitter提供了一种非常简单的方法来预先说明某人的状态以供发布。具体地说,这很容易 我正在寻找一个类似的方法用于facebook。不幸的是,我能找到的只是按钮和类似的东西,它们不符合我的需要(我们想要发布的内容没有自己的页面)。facebook上有什么方法可以轻松设置某人的状态吗?在facebook上,要发布到某个用户的个人资料,您需要以下信息: 用于验证/授权应用程序的用户 您请求获得一个扩展权限,以便能够发布到他的墙上(publish\u stream在本例中) 捕获用户id并使用它发布

Twitter提供了一种非常简单的方法来预先说明某人的状态以供发布。具体地说,这很容易


我正在寻找一个类似的方法用于facebook。不幸的是,我能找到的只是按钮和类似的东西,它们不符合我的需要(我们想要发布的内容没有自己的页面)。facebook上有什么方法可以轻松设置某人的状态吗?

在facebook上,要发布到某个用户的个人资料,您需要以下信息:

  • 用于验证/授权应用程序的用户
  • 您请求获得一个扩展权限,以便能够发布到他的墙上(
    publish\u stream
    在本例中)
  • 捕获用户id并使用它发布您想要的任何内容
  • 现在,执行此操作很简单,可以通过不同的方式完成,让我们使用PHP-SDK页面并对其进行修改:

    <?php
    /**
     * Copyright 2011 Facebook, Inc.
     *
     * Licensed under the Apache License, Version 2.0 (the "License"); you may
     * not use this file except in compliance with the License. You may obtain
     * a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     * License for the specific language governing permissions and limitations
     * under the License.
     */
    
    require '../src/facebook.php';
    
    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array(
      'appId'  => '191149314281714',
      'secret' => '73b67bf1c825fa47efae70a46c18906b',
    ));
    
    // Get User ID
    $user = $facebook->getUser();
    
    // We may or may not have this data based on whether the user is logged in.
    //
    // If we have a $user id here, it means we know the user is logged into
    // Facebook, but we don't know if the access token is valid. An access
    // token is invalid if the user logged out of Facebook.
    
    if ($user) {
      try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');
      } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
      }
    }
    
    // Login or logout url will be needed depending on current user state.
    if ($user) {
      $logoutUrl = $facebook->getLogoutUrl();
    } else {
      $loginUrl = $facebook->getLoginUrl(
        'scope' => 'publish_stream'
      );
    }
    
    // This call will always work since we are fetching public data.
    $naitik = $facebook->api('/naitik');
    
    ?>
    <!doctype html>
    <html xmlns:fb="http://www.facebook.com/2008/fbml">
      <head>
        <title>php-sdk</title>
        <style>
          body {
            font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
          }
          h1 a {
            text-decoration: none;
            color: #3b5998;
          }
          h1 a:hover {
            text-decoration: underline;
          }
        </style>
      </head>
      <body>
        <h1>php-sdk</h1>
    
        <?php if ($user): ?>
          <a href="<?php echo $logoutUrl; ?>">Logout</a>
        <?php else: ?>
          <div>
            Login using OAuth 2.0 handled by the PHP SDK:
            <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
          </div>
        <?php endif ?>
    
        <h3>PHP Session</h3>
        <pre><?php print_r($_SESSION); ?></pre>
    
        <?php if ($user): ?>
          <h3>You</h3>
          <img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
    
          <h3>Your User Object (/me)</h3>
          <pre><?php print_r($user_profile); ?></pre>
        <?php else: ?>
          <strong><em>You are not Connected.</em></strong>
        <?php endif ?>
    
        <h3>Public profile of Naitik</h3>
        <img src="https://graph.facebook.com/naitik/picture">
        <?php echo $naitik['name']; ?>
      </body>
    </html>
    
    现在,用户授予了您的应用程序正确的权限,您可以将其张贴到他的墙上,请参考此内容开始操作。

    这是以前在


    但是现在没有了。

    听起来你只是想用一种简单的方式在Facebook上分享内容。Facebook拒绝使用共享按钮,但似乎仍然支持对共享页面的直接URL调用:

    因此,创建一个链接,在新窗口中打开URL,如下面的Javascript:

    您提到使用默认文本对其进行预填充。我相信Facebook现在明确禁止这样做。他们在中这样说,这应该也涵盖了他们的共享页面政策:

    该字段将在2011年7月12日被忽略,该消息将预先填充用户将键入的文本字段。为了符合Facebook平台策略,只有在用户在工作流的早期手动生成内容时,应用程序才能设置此字段。大多数应用程序不应设置此选项

    $loginUrl = $facebook->getLoginUrl(array(
      "scope" => "publish_stream"
    ));
    
    http://www.facebook.com/sharer/sharer.php?u=cnn.com&t=great+news+site
    
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(myUrl)+'&t='+encodeURIComponent(myTitle),'sharer','toolbar=0,status=0,width=626,height=436');