ios - How to use FBSDKCoreKit to post image to users Facebook -


so totally lost on how post image users timeline fbsdkcorekit. hoping similar twitter coded so:

how can share image status did twitter? don't want have user have dialog slcomposeviewcontroller. want happen in background uiimage provide status text provide.

twitter.sharedinstance().loginwithcompletion { let struploadurl = "https://upload.twitter.com/1.1/media/upload.json"         let strstatusurl = "https://api.twitter.com/1.1/statuses/update.json"         uiapplication.sharedapplication().networkactivityindicatorvisible = true         var twapiclient = twitter.sharedinstance().apiclient         var error: nserror?         var parameters:dictionary = dictionary<string, string>()         var imagedata : nsdata = uiimagejpegrepresentation(self.image!, 0.5)         parameters["media"] = imagedata.base64encodedstringwithoptions(nil)         var twuploadrequest = twapiclient.urlrequestwithmethod("post", url: struploadurl, parameters: parameters, error: &error)         if true {             println("before sendtwitterrequest")             twapiclient.sendtwitterrequest(twuploadrequest) {                 (uploadresponse, uploadresultdata, uploadconnectionerror) -> void in                 println("inside sendtwitterrequest")                 if (uploadconnectionerror == nil) {                     // using swiftyjson parse result                     let json = json(data: uploadresultdata!)                     // check media id in result                     if (json["media_id_string"].string != nil) {                         println("result = \(json)")                         // post status link media                         parameters = dictionary<string, string>()                         parameters["status"] = ""                         parameters["media_ids"] = json["media_id_string"].string!                         var twstatusrequest = twapiclient.urlrequestwithmethod("post", url: strstatusurl, parameters: parameters, error: &error)                         if true //(twstatusrequest != nil)                         {                             twapiclient.sendtwitterrequest(twstatusrequest) { (statusresponse, statusdata, statusconnectionerror) -> void in                                 if (statusconnectionerror != nil) {                                     println("error posting status \(statusconnectionerror)")                                 }                             } // completion                         } else {                             println("error creating status request \(error)")                         }                     } else {                         println("media_id not found in result = \(json)")                     }                 } else {                     println("error uploading image \(uploadconnectionerror)")                 }             } // completion         } else {             println("error creating upload request \(error)")         }  } 

this documented in "sharing on ios" section of documentation.

assuming completed the basic setup of installing sdk , configuring xcode project, should implement facebook login first , ask publish_actions permission (note: permission requires prior review facebook before can used non-app admins/developers/testers).

after have implemented this, can go earlier mentioned "sharing on ios" guide reference , use [fbsdkshareapi sharewithcontent:content delegate:nil]; publish content using api directly instead of dialog.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -