简体   繁体   中英

Facebook Javascript SDK share to facebook wall

I am getting an error: 'share' is not a member of 'ASP.default2_aspx'.
OnClick of Button1, I need this data TxtLocation, TxtDistance, Date to be shared on Facebook. Its very similar to 'Run with friends app' Simulate the same as Run with friends app'. So would it be possible to use a fb.ui stream_publish method on click of Button1 with all the three text box vales. This is what I have in default.aspx

            //stream publish method
            function streamPublish(name, description, hrefTitle, hrefLink, userPrompt) {
                FB.ui(
                {
                    method: 'stream.publish',
                    message: '',
                    attachment: {
                        name: name,
                        caption: '',
                        description: (description),
                        href: hrefLink
                    },
                    action_links: [
                        { text: hrefTitle, href: hrefLink }
                    ],
                    user_prompt_message: userPrompt
                },
                function (response) {

                });

            }


            function share() {
                var share = {
                    method: 'stream.share',
                    u: 'http://thinkdiff.net/'
                };

                FB.ui(share, function (response) { console.log(response); });
            }


        </script>


        <p><fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button></p>

   <form id = "form1" runat="server">

    <div id="Event" runat="server">
        <h1>
            Add your event</h1>
        <table>
            <tr>
                <td>
                    Where did you go
                </td>
                <td>
                    <asp:TextBox ID="TxtLocation" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Number of miles
                </td>
                <td>
                    <asp:TextBox ID="TxtDistance" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Date(MM/DD/YYYY)
                </td>
                <td>
                    <asp:TextBox ID="TxtDate" runat="server">TxtDate</asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="Button1" runat="server" Text="Add Distance"  onclick="share();return false" BackColor="Blue" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

Maybe it's because share is already the name of the function.

Try changing the name of the var inside the function share.

Bye ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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