Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12830] iOS Facebook v3 Module: Cannot create an event using the GRAPH API

GitHub Issuen/a
TypeBug
PriorityLow
StatusReopened
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterBenjamin Hatfield
AssigneeUnknown
Created2013-02-22T22:47:13.000+0000
Updated2018-02-28T20:03:43.000+0000

Description

REPRODUCTION: Run the code below with 3.1.0 and the Facebook v3 module on the iOS simulator. After logging in, click the button to try and post an event. RESULTS: On the iOS platform, the API call fails. The console outputs: {noformat} [ERROR] :  : HTTP status code: 400 {noformat} and an alert dialog displays: {noformat} The operation couldn't be completed. (com.facebook.sdk error 5.) {noformat} On the Android platform, the GRAPH API call succeeds. ADDITIONAL NOTES: With 3.0.2.GA, the code runs OK on both Android and iOS. The other examples mentioned in http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Facebook work except the logout example for iOS (TIMOB-12828). TEST CODE:
//var fb = Ti.Facebook;
var fb = require('facebook');
fb.appid = 495338853813822;
fb.permissions = ['create_event'];
fb.addEventListener('login', function(e) {
    if (e.success) {
        alert('Logged In');
    } else if (e.error) {
        alert(e.error);
    } else if (e.cancelled) {
        alert("Canceled");
    }
});

var evt = Ti.UI.createButton({title: 'GRAPH Create Event'});
evt.addEventListener('click', function(e){
	var starttime = new Date(2013, 4, 30, 17, 0);
	var endtime = new Date(2013, 4, 30, 19, 0);
	var title = "Barry's Birthday Celebration";
	var description = "Barry will have a great party";
	var data = {
	    start_time: JSON.stringify(starttime), // API expects a JSON stringified date
	    end_time: JSON.stringify(endtime),
	    summary: description,
	    name: title
	};
	fb.requestWithGraphPath('me/events', data, 'POST', function(e) {
	    if (e.success) {
	        alert("Success! Returned from FB: " + e.result);
	    } else {
	        if (e.error) {
	            alert(e.error);
	        } else {
	            alert("Unknown result");
	        }
	    }
	});
});

var win = Ti.UI.createWindow({backgroundColor: 'white'});
win.add(evt);
win.open();

if (!fb.loggedIn) {
	fb.authorize();
}

Comments

  1. Benjamin Hatfield 2013-02-22

    Found some new information. Investigating.
  2. Benjamin Hatfield 2013-02-22

    Also tried using the reauthorize method. Did not work for creating an event, but did work for posting a status update.
       // Initialization
       ...
       fb.permissions = ['read_stream'];
       fb.forceDialogAuth = false;
       ...
       // After setting up the data dict object...
       
           fb.reauthorize(['create_event'], 'everyone', function(e){
           if (e.success) {
               fb.requestWithGraphPath('me/events', data, 'POST', function(e) {  
       ...          
       
       

JSON Source