In the app, I want to post a photo, and some text. I am able to post if I am using local stored data in resources but when data (in JSON format) is coming from server at the run time, I am not able to post that image and text which is coming from server in the JSON format.
Is there any way to post data at the runtime or I have to store the data at the client side, but in that case, the app will be bulky because data could be different at different locations?
I am not sure but you may be asking about posting an image using a URL instead of assuming data is local. If so, see this blog post - https://developers.facebook.com/blog/post/526/ and it introduced the ability to post an image by passing in a "url" parameter through the Graph API.
Related
I am trying to send an API request in my flutter App for filtering the items in my app. I want the data to be filtered between certain 2 numbers.
This is what I want.
http://3.237.223.130/careWorker/get-parttime-jobList?workingHoursFrom=02.30&workingHoursTo=03.00
but the API call going from the app looks like this
http://3.237.223.130/careWorker/get-parttime-jobList?workingHoursFrom=02%3A30&workingHoursTo=03%3A00
The '.' is being converted into '%3A'
How can I send the API request in the form I want?
Both of them is the same value.
Seems like the query parameters are being urlEncoded while sending via API.
I have attached the image to show you the example.
You can test the URL encoded and decoded value HERE.
I am creating an API.
I am unsure what the API should look like.
Several BLOB files (PDF, JPG, ZIP, ...) should get uploaded and
some JSON which contains meta data.
What is the most up-to-date way to design the API?
There are two cases:
the upload was successful. Then I think 201 (created) would be feasible
the upload was not successful (for example invalid meta data). Then 422 (Unprocessable Entity) should get returned.
Example:
Three pdf-files should get uploaded (at once) associated with some json meta data.
What you often see is that you have a resource for handling the BLOBs and one for the meta-data - Facebook and Twitter is doing this for images and videos.
For example /files would take your BLOB data and return an ID for the uploaded BLOB data.
The metadata would be send to another resource, called /posts and could consume application/json.
In the application I currently work for, we had the same issue and decided to use one endpoint consuming multipart/form-data - here you can send the BLOBs and the metadata within different boundaries and have everything in one resource.
Another way would be to base64 encode the BLOBs, which will result in an 33 % overhead, and I therefore not recommend it. But with base64 you could do all your work in one application/json resource.
I know for getting a data we have to use a GET request. But this time I have to send a XML document (who will not be stored) for getting the data. What are the best practice in this case ?
You need send a xml document to your end-point to get your interested data.
As you need a xml doc, it has to be a POST REST end-point. (On a side note, sending any file contents as part of GET parameters is a bad design practice.)
The Facebook Open Graph Debugger does a terrific job of taking a URL and parsing / loading it into a title / description / image / etc. Does this API expose a JSON format or does a similar service exist for 'linting' URLs into more rich objects? I'm trying to do an iOS integration. Obviously I'd like to avoid parsing XML and extracting the metadata myself if possible.
https://developers.facebook.com/docs/sharing/opengraph/using-objects#update
“This Graph API endpoint is simply a call to: POST /?id={object-instance-id or object-url}&scrape=true The response from this endpoint will be a JSON object that contains all the information about the object that was scraped (the same data returned when the Object ID is read from the Graph API).”
I noticed couple thread on this already and they even provided sample code.
http://brunofuster.wordpress.com/2010/11/03/uploading-an-image-from-iphone-with-uiimagepicker-and-asihttprequests3/
But what baffled me is that - there was no response to get handled? is it because that s3 doesn't return any response? I am expecting to receive at least an URL to the image on S3, how could I get that?
If you look at the S3 REST object PUT documentation you will see the response that is returned from S3.
When you post to S3 you know the bucket name you are putting the image into plus you know the filename. These two pieces of information should be all you need to get a url to the image.
The documentation states that in addition to the PUT response header(s) you can see some of the common headers too.
This implementation of the operation
can include the following response
headers in addition to the response
headers common to all responses. For
more information, see Common Response
Headers.
If you look at the ASIHTTPRequest Amazon Simple Storage Service (S3) support you will see how to get a response from the ASIS3ObjectRequest object.
Tom,
If you wish to just get your S3 image url, you don't need the response information considering you already know the image name and the bucket (if there was no error).
Anyway, you can get the response from a sync request by using [request responseString|responseData].
But the right thing to do is an async call using operation queues and delegates to get the response success or error. My blog post just provided a minimal sample. I will look into that and improve the post itself.
Thanks!
In addition to the answers already provided, you might also want to look at Amazon's recently released AWS SDK for iOS, which includes sample code for uploading images, etc. to S3.