FBSDKGraphRequest can no longer post images and text (more text)

I post to the user wall of the group (image and text). It has been working since ancient times and has stopped working recently (now the image is posted, but there is no text :(). Any idea if there was a new method or rules? (No error was reported)

    [params setObject:sContent forKey:@"message"];
    [params setObject:yourImageData forKey:@"picture"];



    [[[FBSDKGraphRequest alloc]
      initWithGraphPath:@"xxxxxxxxxxxxxxx/photos"
      parameters: params
      HTTPMethod:@"POST"]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error) {
+4
source share
1 answer

Below is the working code for me (In Swift):

let params = ["message": "Test message", "sourceImage" : UIImagePNGRepresentation(UIImage(named: "test.jpg")!)!]
FBSDKGraphRequest(graphPath: "me/photos", parameters: params, HTTPMethod: "POST").startWithCompletionHandler({ (connection, result, error) -> Void in
    guard let response = result else {
        print("No response received")
        if let errorInfo = error {
            print("errorInfo: \(errorInfo)")
        }
        return }

    print(response)
})

Check the "Publish" section in for more details.

Let me know if you have difficulty converting it to Objective-C.

+2
source

All Articles