Create a facebook event using javascript and facebook connect - Stack Overflow

admin2025-04-08  1

I'm building a site that uses facebook connect. Is it possible to create facebook events on the site and invite friends and publish this event on facebook just using javascript?

I've had a look on developers.facebook, but can't work out if the Graph API is what I'm looking for or if that is only open to facebook apps.

I'm building a site that uses facebook connect. Is it possible to create facebook events on the site and invite friends and publish this event on facebook just using javascript?

I've had a look on developers.facebook., but can't work out if the Graph API is what I'm looking for or if that is only open to facebook apps.

Share Improve this question asked Feb 1, 2011 at 22:42 gprgpr 9591 gold badge10 silver badges23 bronze badges 1
  • I dont think that you can create event of facebook at your site. however you can publish any thing to your site and you can invite your friends – Awais Qarni Commented Feb 2, 2011 at 10:57
Add a ment  | 

2 Answers 2

Reset to default 6

UPDATE

create_event is no longer available from v2.0 and hence it's no longer possible to create events through the API. ref


Here you go:
Required Permissions: create_event

JS to create an event:

$('#create-event').click(function() {
    FB.api('/me/events','post',{name:"JS-SDK Event",start_time:1272718027,location:"Here"},function(resp) {
        console.log(resp.id);
    });
    return false;
});

JS to invite friends, using the invited connection:

$('#invite-event').click(function() {
    FB.api('/EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3','post',function(resp) {
        console.log(resp); // should return true
    });
    return false;
});

Try this:

function Login(){
FB.login(function(response) {


       if (response.authResponse) {
         var access_token =   FB.getAuthResponse()['accessToken'];
       //  alert('Access Token = '+ access_token);
         FB.api('/me', function(response) {
        alert('wele ' + response.name + '.');


        FB.api('/me/events','post',{ 
            name: 'TEST',
            start_time: '2013-06-03T15:00:00-0700',
            end_time:   '2013-06-03T19:00:00-0700',
            description:'Birthday party',
            location:'Mumbai',
            privacy_type:"OPEN",

        },

        function(response) {

             // alert(response.name);

              console.log(response);

              alert(response.id);
              eventid(response.id);

        });
         });
       } else {
          // callAjaxlogout();



        //alert('User cancelled login or did not fully authorize.');
       }
     },{scope: 'create_event,user_events'});

}

HTML:

/*required permissions:create_event,user_events;*/

<button id="login" name="login" onclick="Login()">Login</button>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744127641a232538.html

最新回复(0)