How to use Facebook PHP API to upload a photo to wall without file POST? (Using a URL maybe?)

牧云@^-^@ 提交于 2019-12-13 04:41:25

问题


I'm doing preliminary research for an upcoming project. Basically here is the user/data flow:

  • A webcam at an event takes pictures and sends the photos to a local server

  • A brand rep has an iPad with an app (developed as an HTML app saved to iPad home screen as an app). The app displays all photos from the local server as thumbnails via simple AJAX calls to load them into the view.

  • A user selects a photo. That photo will be sent from our local server to our remote server. The remote server will host a Facebook iFrame tab with the user selected photos.

  • At the same time, a link to the iFrame tab with a query string will be posted on the user's Facebook wall and Twitter (if they choose to authenticate of course).

Now the tricky part, we are 99% sure that the client is going to want to also upload the photo directly to the Facebook user's album. Possibly to TwitPic as well but that is a secondary concern. So my question is, is there a way to use PHP to upload a photo to a Facebook wall without using a typical html file input field and POST? Ideally, if we can do some kind of a file_get_contents on the photo URL from the local server and use PHP/FB API to upload the contents of the photo URL, we'd be in great shape.

The goal is to have the photo uploaded to the user wall with a caption like:

Check out my photo taken at _ event! [URL to client facebook tab with photo id].


回答1:


@jeremyharris is right to say that Facebook's PHP SDK wraps cURL. You indeed need to use cURL to post a request to Facebook's API endpoint. Though, start by reading http://developers.facebook.com/docs/reference/api/ Publishing section to understand the mechanics before you jump onto their SDK.

Then familiarise with the feed object. You can use either it or the photo object to upload the photo.



来源:https://stackoverflow.com/questions/11040848/how-to-use-facebook-php-api-to-upload-a-photo-to-wall-without-file-post-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!