bobolounna / restfb

Automatically exported from code.google.com/p/restfb
0 stars 0 forks source link

Problem in photo upload #183

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. following the example in the page, having a correct and valid access token.
2. debugging code to ensure passing parameters correctly
3. execute this call:

FacebookType publishPhotoResponse = facebookClient.publish("me/photos", 
FacebookType.class,
  BinaryAttachment.with(fileName, theSequenceInputStreamIGotFromResteasy),
  Parameter.with("message", "Test cat"));

What is the expected output? What do you see instead?
It worked once on December 2011, then after December this code always fails! I 
expect to see the photo uploaded on Facebook and the publushed post id 
returned. None of those happens: I receive Facebook OAuthException: (#324) 
Missing or invalid image file.

What version of the product are you using? On what operating system?
restfb 1.6.9

Please provide any additional information below.
Don't know what else can I say, try again this piece of code and tell me if it 
happens to you too with this version of RestFB. It's not a Facebook problem 
because I tried the graph API using a REST console and the photos were uploaded 
correctly.

Original issue reported on code.google.com by riccardo...@gmail.com on 5 Apr 2012 at 7:46

GoogleCodeExporter commented 8 years ago
I forgot: I have this issue both on Windows and on Mac.

Original comment by riccardo...@gmail.com on 5 Apr 2012 at 7:47

GoogleCodeExporter commented 8 years ago
Hm, let me check into it.  According to Google this has been a problem for 
others and sounds like it might be a bug on FB's end (people are reporting it's 
intermittent), or there may be an issue with the access token used to do the 
post.  See 
https://developers.facebook.com/bugs/186962478087789/?browse=search_4f7a913dd260
13433354453 and Google for "OAuthException: (#324) Missing or invalid image 
file." for more details

Original comment by m...@xmog.com on 5 Apr 2012 at 1:46

GoogleCodeExporter commented 8 years ago
Thanks for the answer I already googled, but without finding a common problem 
about this situation.

Anyway I don't think it's a facebook problem because if you try to issue an 
HTTP POST multipart to me/photos using facebook Graph API documentation it 
works fine (BTW it works using the same access token that fails on RestFB call).

If you test a photo publish using RestFB does it works correctly?

Original comment by riccardo...@gmail.com on 5 Apr 2012 at 3:01

GoogleCodeExporter commented 8 years ago
I have just verified that this works correctly using an access token generated 
by the Graph API explorer (see attached image for my permissions and attached 
cat.png pic).  Here is my code:

String accessToken = "XXX";

FacebookType publishPhotoResponse =
    new DefaultFacebookClient(accessToken).publish("me/photos", FacebookType.class,
      BinaryAttachment.with("cat.png", Tester.class.getResourceAsStream("/cat.png")),
      Parameter.with("message", "Test cat"));

System.out.println("Published photo ID: " + publishPhotoResponse.getId());

Original comment by m...@xmog.com on 5 Apr 2012 at 3:09

Attachments:

GoogleCodeExporter commented 8 years ago
I am also seeing the same problem. 
I went to facebook, and generated a new graph access-token with permissions 
matching the ones mentioned above.
Then I ran the GrapthPublisherExample that comes with restFB.
The first run, the photo was uploaded successfully, but all subsequent runs 
fail. Facebook returns 200 OK.

I will appreciate any help with this issue.

Thanks.

This is what I do:
C:\restfb-1.6.9\source\example>ant run-publisher-examples 
"-Daccess_token=my_token"

Buildfile: C:\cz\restfb-1.6.9\source\example\build.xml

compile:
     [echo] Compiling examples...
    [javac] C:\restfb-1.6.9\source\example\build.xml:28: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

run-publisher-examples:
     [java] * Binary file publishing *
     [java] Apr 18, 2012 4:31:38 PM com.restfb.DefaultWebRequestor executePost
     [java] INFO: Executing a POST to https://graph.facebook.com/me/photos with parameters message=Test cat&access_token=my_token&format=json and 1 binary attachment[s].
     [java] Apr 18, 2012 4:31:54 PM com.restfb.DefaultFacebookClient makeRequestAndProcessResponse
     [java] INFO: Facebook responded with HTTP status code 200 and response body: {"id":"407004595982232","post_id":"100000408846376_406963045992227"}
     [java] Published photo ID: 407004595982232

BUILD SUCCESSFUL
Total time: 17 seconds

Original comment by sandeepa...@gmail.com on 18 Apr 2012 at 11:05

GoogleCodeExporter commented 8 years ago
Can you show an example of where the call fails?  The snippet you provided 
shows it working correctly.

Original comment by m...@xmog.com on 19 Apr 2012 at 2:26

GoogleCodeExporter commented 8 years ago
Thanks for your reply. We got it working today by adding publish_photo 
permission to the access token.

Original comment by sandeepa...@gmail.com on 19 Apr 2012 at 5:26

GoogleCodeExporter commented 8 years ago
Sounds like everything is good with correct permissions - closing this out.

Original comment by m...@xmog.com on 12 Jul 2012 at 2:21