dhaval shah
dhaval shah

Reputation: 4549

create event on facebook via graph api or javascript sdk

I want a "create event facebook popup" with preconfigured parameters.

I have bit of coding as below but i am really confused how we can go further.

My Code below

<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '<appid>',
            xfbml      : true,
            version    : 'v2.2'
        });   
    };

    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {
            return;
        }
        js = d.createElement(s);
        js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

<a href="#" onclick="callEvent()"> <span>     Create Event    </span></a>

<script>
    function callEvent() {
        FB.getLoginStatus(function(response) {
            if (response.status === 'connected') {
                console.log('Logged in.');
                var accessToken = response.authResponse.accessToken;
                alert(accessToken);
                FB.api('/me/events?access_token=' + accessToken, 'post',
                    {
                        name:       "Test    event",
                        start_time: Math.round(new Date().getTime()/1000.0)
                    },
                    function(retVal) {}
                );
            }
            else {
                console.log('initiate FB login...');
                FB.login();
            }
        });
    }
</script>

Can someone help with code? Thanks in advance.

Upvotes: 0

Views: 660

Answers (1)

andyrandy
andyrandy

Reputation: 73984

You cannot create events via the Graph API.

Source: https://developers.facebook.com/docs/graph-api/reference/v2.3/event#publish

Specifically, about user events:

Creating

You can't perform this operation on this endpoint.

Source: https://developers.facebook.com/docs/graph-api/reference/user/events

Upvotes: 1

Related Questions