Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use the Attachment Upload API with RestFB? #1063

Closed
torbenw opened this issue Mar 6, 2020 · 3 comments
Closed

Is it possible to use the Attachment Upload API with RestFB? #1063

torbenw opened this issue Mar 6, 2020 · 3 comments
Assignees
Milestone

Comments

@torbenw
Copy link

torbenw commented Mar 6, 2020

I'm trying to switch from the old Conversations API to the newer Send API. With the old API it was possible to send attachments as BinaryAttachments without uploading them first. With the Send API this doesn't seem to be possible.

Are there any classes for the requests and responses of the Attachment Upload API in RestFB? I don't see any. The example for using the Send API only shows how it can be done using a link.

Is there a way RestFB can help me with this or do I have to write my own classes for the requests and responses?

@nbartels
Copy link
Contributor

nbartels commented Mar 6, 2020

Please check issue #1062

We are working on this topic and provide an example code in the documentation as soon as it is resolved

@torbenw
Copy link
Author

torbenw commented Mar 6, 2020

Thank you for the quick response! Sorry, I didn't see that issue.

That's exactly what I'm trying right now, but I'm not sure if it's possible to somehow do a form-data request with the RestFB client or if I would have to use another client for that.

Do you know when your example code would be ready?

I just checked again and it's not exactly what I was looking at before. I was looking at the "Attachment Upload API".

curl \ -F 'message={"attachment":{"type":"image", "payload":{"is_reusable":true}}}' \ -F 'filedata=@/tmp/shirt.png;type=image/png' \ "https://graph.facebook.com/v6.0/me/message_attachments?access_token=<PAGE_ACCESS_TOKEN>"

But your request doesn't require an upload before sending the message as mentioned in #1006.

curl \ -F 'recipient={"id":"<PSID>"}' \ -F 'message={"attachment":{"type":"<ASSET_TYPE>", "payload":{"is_reusable"=true}}}' \ -F 'filedata=@/tmp/shirt.png;type=image/png' \ "https://graph.facebook.com/v6.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

It is very similar, though. But both versions aren't currently supported by RestFB.

@nbartels
Copy link
Contributor

nbartels commented Mar 6, 2020

I added an example to #1062 and I try to push the necessary code to restfb this weekend, maybe this evening. The publishing code can be found in the other issue, too.

Would be great if you simply track 1062 then, I can close this duplicate here ;)

Thanks for the feedback.

@nbartels nbartels added this to the 3.4.0 milestone Mar 8, 2020
@nbartels nbartels self-assigned this Mar 8, 2020
@nbartels nbartels closed this as completed Mar 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants