Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

How to create a Facebook Place using simple HTTP Post or the FB Module?

$
0
0

Hey guys, i tried a couple of alternatives to creating a FB Place like I managed to do with FB Events using the FB Module, however both were unsuccessful.

I noticed that the API doesn't support this, but graph api does. https://developers.facebook.com/docs/reference/opengraph/object-type/place/

Can anyone give a hand or post some sample code for me plz?

FIRST try:

var placeData = {
            'fb:app_id':appId,
            'og:type':'place',
            'og:url':placeUrl,
            'og:title':tfCPName.value,
            'og:image':placeImage,
            'place:location:latitude':latitude,
            'place:location:longitude':longitude,',
            // also tried putting access_token here but it also didnt work.         
        }; // end placeData
        var xhr = Ti.Network.createHTTPClient();
        var url = 'https://graph.facebook.com/me/objects/places'; Ti.API.info('Create Place Url: '+url);
 
        xhr.onerror = function(e){ Ti.UI.createAlertDialog({title:'Places',message:'Error creating Place: '+e.error}).show(); Ti.API.info('Place Error Response: '+JSON.stringify(e));};
 
        xhr.onload = function(e){
            var response = this.responseText;
            Ti.API.info('Place Response #1:'+JSON.stringify(e));
            Ti.API.info('Place Response #2:'+JSON.stringify(response));
        }; // end xhr.onload
 
        xhr.open("POST", url);
        xhr.send(placeData);

SECOND try:

var placeData2 = {
            name:tfCPName.value,
            description:tfCPDescription.value,
            latitude:latitude,
            longitude:longitude,
        }; // placeData2    
 
       fb.requestWithGraphPath('me/place', placeData2, 'POST', function(e) { // also tried /me/objects/place
            if (e.success) {
                Ti.API.info('FB Place Created: '+JSON.stringify(e));
                alertCP = Ti.UI.createAlertDialog({
                    title:'Place Creation',
                    message:'Place ' + tfCPName.value + ' created!',
                });
                alertCP.show();             
                setTimeout(function(e){CPClose();},250);
            } else {
                if (e.error) {
                    Ti.API.info('Create Place Error: '+JSON.stringify(e));
                    alert("Erro ->"+e.error);
                } else {
                    Ti.API.info('Create Place Error: '+JSON.stringify(e));
                    alert("Unknown result");
                }
            }
        });
RESPONSE:
[INFO] Create Place Error: {"type":"result","path":"me/place","graph":true,"success":false,"code":5,"source":{"id":"facebook"},"error":"The operation couldn’t be completed. (com.facebook.sdk error 5.)
Using the latest version of Titanium, FB Module and creating an app for iOS.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>