简体   繁体   English

如何通过Graph API在朋友的墙上发布供稿项目

[英]How to post a feed item in friend's wall via Graph API

I am making a very simple gift application on Facebook. 我正在Facebook上做一个非常简单的礼物申请。 The main problem here is how to notify the user which don't use the application about the fact that his friend send him a gift? 这里的主要问题是如何通知不使用该应用程序的用户有关其朋友向他发送礼物的事实?

As the Notifications are disabled on old REST API and stream.publish will not work on the friends who didn't authorize to post on their wall, I am confused. 由于在旧的REST API上禁用了通知,并且stream.publish不适用于未授权在自己的墙上发帖的朋友,我感到困惑。

if (!empty($_REQUEST["ids"]) ) {
    $friends = ( isset($_REQUEST["ids"]) ) ? $_REQUEST["ids"] : 0;

    if (empty($_POST['giftname']) ) {
        $gname = '1.gif';
    } else {
        $gname = $this->input->post('giftname');
    }
    //$this->app_model->send_gift( $user, $friends, $gname,$facebook );
    //$this->app_model->send_gift( $user, $friends, $gname,$facebook );
    $to=$friends;
    $from=$user;
    $gift=$gname;

    $total_send=count($friends);

    for ($x=0; $x<$total_send; $x++ ) {

        $this->db->query("INSERT INTO gifts (`giftfrom`, `giftto`, `gname`) VALUES( $from, $to[$x], \"$gift\" )");

        try {
            // Send notification
            //$facebook->api_client->notifications_send($to[$x], 'sent you a gift using <a href="http://apps.facebook.com/tsaxikner/">Հայկական Նվերներ</a>. <a href="http://apps.facebook.com/tsaxikner/">Ստանալ Նվերը</a>.');

            // Publish feed story
            $feed_body = '<fb:userlink uid="'.$from.'" shownetwork="false"/>-ը նվեր է ուղարկել <fb:name uid="'.$to[$x].'"/>-ին  <a href="http://apps.facebook.com/tsaxikner/">Հայկական Նվերներ</a>-ի միջոցով.';

            $feed_body = 'Ստուգեք <a href="http://apps.facebook.com/tsaxikner/"> <fb:name uid="'.$to[$x].'" firstnameonly="true" possessive="true"/> Հայկական Նվերներ</a>.';

            //$facebook->api_client->feed_publishActionOfUser($feed_title, $feed_body);
            $facebook->api_client->make_wall_post($user,$to[$x],$feed_body);
            $facebook->api_client->notifications_sendEmail($user, 'You have a gift', $feed_body, $fbml);

            //$facebook_graph->api('' $message, null, null, $target_id );
        }
        catch(Exception $e) {
            echo $e->getMessage();
        }
    }
    // end of for
}

I use FBML 我使用FBML

I can post on the user's friends walls via the PHP API. 我可以通过PHP API张贴在用户的好友墙上。

Try this : 尝试这个 :

$facebook->api('/[FRIEND_ID]/feed', 'post', array(
          'message' => 'test message',
          'link' => 'http://google.com',
          'name' => 'test name',
          'caption' => 'test caption',
          'description' => 'test long description',
      ));

It sounds like a request would be a more appropriate (and effective) channel for this communication. 听起来, 请求将是此通信的更合适(更有效)的渠道。 With a request you have the added benefit of the notification that will be automatically generated along with your request. 有了请求,您将获得通知的附加好处,该通知将随请求一起自动生成。 You can very easily send requests using the Requests dialog . 您可以使用“ 请求”对话框非常轻松地发送请求。

To answer your original question though, as long as you have the "publish_stream" permission and the user whose access token you're using is allowed to post on the recipient's wall (that's a privacy setting that could be set), all you need to do is issue a POST request to: 不过,要回答您的原始问题,只要您具有“ publish_stream” 权限,并且允许您使用其访问令牌的用户发布在收件人的墙上(可以设置此隐私设置),则您需要做的所有事情发出POST请求到:

https://graph.facebook.com/USER2ID/feed?link=YOURLINK

(You can find the parameters for posting a feed story here .) If you're using the PHP SDK, make sure you upgrade to version 3 (it's required that you upgrade by September 1st anyways). (您可以找到这些参数张贴饲料的故事在这里 。)如果你使用的PHP SDK,请确保您升级到版本3 (它需要你9月1日升级反正)。

Its no longer possible. 它不再可能。 You need to use the Feed Dialog to do so. 您需要使用“ 提要”对话框来执行此操作。

There is no way to post on another persons wall directly. 无法直接在其他人的墙上张贴。 If you want to invite them to user your app you will have to use the request-form-submit fbml tag. 如果您想邀请他们使用您的应用,则必须使用request-form-submit fbml标签。 You can find this here: http://developers.facebook.com/docs/reference/fbml/request-form-submit . 您可以在这里找到它: http : //developers.facebook.com/docs/reference/fbml/request-form-submit After that user has allowed your app you can then post on their wall. 在该用户允许您的应用之后,您可以在其墙上发布信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM