Start a new topic

Can't post open graph to facebook

A collection is created on kinvey for the kinvey entity but not the facebook entity. Here's the stack trace



04-22 02:04:58.328: W/System.err(12266): at com.google.api.client.util.IOUtils.copy(IOUtils.java:94)

04-22 02:04:58.329: W/System.err(12266): at com.google.api.client.util.IOUtils.copy(IOUtils.java:63)

04-22 02:04:58.329: W/System.err(12266): at com.google.api.client.http.HttpResponse.parseAsString(HttpResponse.java:515)

04-22 02:04:58.329: W/System.err(12266): at com.google.api.client.http.HttpResponseException$Builder.(HttpResponseException.java:175)

04-22 02:04:58.329: W/System.err(12266): at com.google.api.client.http.HttpResponseException.(HttpResponseException.java:68)

04-22 02:04:58.330: W/System.err(12266): at com.kinvey.java.core.KinveyJsonResponseException.(KinveyJsonResponseException.java:47)

04-22 02:04:58.330: W/System.err(12266): at com.kinvey.java.core.KinveyJsonResponseException.from(KinveyJsonResponseException.java:87)

04-22 02:04:58.331: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:70)

04-22 02:04:58.331: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:28)

04-22 02:04:58.331: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:345)

04-22 02:04:58.331: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:297)

04-22 02:04:58.332: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:370)

04-22 02:04:58.332: W/System.err(12266): at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.offlineFromService(AbstractKinveyOfflineClientRequest.java:129)

04-22 02:04:58.333: W/System.err(12266): at com.kinvey.java.offline.OfflinePolicy$1.execute(OfflinePolicy.java:42)

04-22 02:04:58.334: W/System.err(12266): at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.execute(AbstractKinveyOfflineClientRequest.java:155)

04-22 02:04:58.334: W/System.err(12266): at com.kinvey.android.AsyncAppData$SaveRequest.executeAsync(AsyncAppData.java:623)

04-22 02:04:58.334: W/System.err(12266): at com.kinvey.android.AsyncClientRequest.doInBackground(AsyncClientRequest.java:71)

04-22 02:04:58.335: W/System.err(12266): at android.os.AsyncTask$2.call(AsyncTask.java:288)

04-22 02:04:58.336: W/System.err(12266): at java.util.concurrent.FutureTask.run(FutureTask.java:237)

04-22 02:04:58.336: W/System.err(12266): at com.kinvey.android.AsyncClientRequest$KinveySerialExecutor$1.run(AsyncClientRequest.java:145)

04-22 02:04:58.336: W/System.err(12266): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

04-22 02:04:58.337: W/System.err(12266): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

04-22 02:04:58.338: W/System.err(12266): at java.lang.Thread.run(Thread.java:841)

04-22 02:04:58.339: W/System.err(12266): com.kinvey.java.core.KinveyJsonResponseException:

04-22 02:04:58.339: W/System.err(12266): null

04-22 02:04:58.340: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:70)

04-22 02:04:58.341: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:28)

04-22 02:04:58.341: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:345)

04-22 02:04:58.341: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:297)

04-22 02:04:58.342: W/System.err(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:370)

04-22 02:04:58.342: W/System.err(12266): at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.offlineFromService(AbstractKinveyOfflineClientRequest.java:129)

04-22 02:04:58.343: W/System.err(12266): at com.kinvey.java.offline.OfflinePolicy$1.execute(OfflinePolicy.java:42)

04-22 02:04:58.343: W/System.err(12266): at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.execute(AbstractKinveyOfflineClientRequest.java:155)

04-22 02:04:58.343: W/System.err(12266): at com.kinvey.android.AsyncAppData$SaveRequest.executeAsync(AsyncAppData.java:623)

04-22 02:04:58.344: W/System.err(12266): at com.kinvey.android.AsyncClientRequest.doInBackground(AsyncClientRequest.java:71)

04-22 02:04:58.344: W/System.err(12266): at android.os.AsyncTask$2.call(AsyncTask.java:288)

04-22 02:04:58.345: W/System.err(12266): at java.util.concurrent.FutureTask.run(FutureTask.java:237)

04-22 02:04:58.345: W/System.err(12266): at com.kinvey.android.AsyncClientRequest$KinveySerialExecutor$1.run(AsyncClientRequest.java:145)

04-22 02:04:58.346: W/System.err(12266): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

04-22 02:04:58.346: W/System.err(12266): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

04-22 02:04:58.346: W/System.err(12266): at java.lang.Thread.run(Thread.java:841)

04-22 02:04:58.348: E/facebook(12266): Failed to post to OpenGraph

04-22 02:04:58.348: E/facebook(12266): com.kinvey.java.core.KinveyJsonResponseException:

04-22 02:04:58.348: E/facebook(12266): null

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:70)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:28)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:345)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:297)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:370)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.offlineFromService(AbstractKinveyOfflineClientRequest.java:129)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.java.offline.OfflinePolicy$1.execute(OfflinePolicy.java:42)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.execute(AbstractKinveyOfflineClientRequest.java:155)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.android.AsyncAppData$SaveRequest.executeAsync(AsyncAppData.java:623)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.android.AsyncClientRequest.doInBackground(AsyncClientRequest.java:71)

04-22 02:04:58.348: E/facebook(12266): at android.os.AsyncTask$2.call(AsyncTask.java:288)

04-22 02:04:58.348: E/facebook(12266): at java.util.concurrent.FutureTask.run(FutureTask.java:237)

04-22 02:04:58.348: E/facebook(12266): at com.kinvey.android.AsyncClientRequest$KinveySerialExecutor$1.run(AsyncClientRequest.java:145)

04-22 02:04:58.348: E/facebook(12266): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

04-22 02:04:58.348: E/facebook(12266): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

04-22 02:04:58.348: E/facebook(12266): at java.lang.Thread.run(Thread.java:841)

hmmm.



Can you open up the API Console addon: https://console.kinvey.com/addons/api-console



and on that top bar that shows a URL make it look like this:



/blob/kid_VV6bhk7MNq/



note it defaults to /appdata// ---- so replace `appdata` with `blob`, leave your `KID` the same, and then copy and paste the ID of that uploaded file after the `/` following the kid.



it should like this, but I'm not manually typing out the complete file id -> /blob/kid_VV6bhk7MNq/Project_09b7d227-





Then perform the request, and below it you should see json data. Can you copy and paste that here?
Hi Edward,



Yes the file is being uploaded. See attachment.



![](https://c3409409.ssl.cf0.rackcdn.com/kinvey.vanillaforums.com/editor/s3/61flfty1pstz.png "")

can you visit console.kinvey.com and ensure the file is properly uploaded? It will appear in the file addon
Nope, that returns a null too...
try `getMetadata().getUploadURL()` instead, sorry about that!
Any idea on why getMetadata().getDownloadURL() returns a null above? Is there another call to get the url for the image?
The main debug line got jumbled above:



04-28 15:42:20.650: I/Facebook(9052): 'image saved successfully imageURL:null'
Thanks Edwards. We are getting close :smiley:



The only issue now is that getMetaData().getDownloadURL() returns null



DEBUG LOGS:



04-28 15:42:19.316: I/System.out(9052): Kinvey - Client - File | mimetype from stream found as: null

04-28 15:42:19.325: I/Kinvey - Client(9052): size is: 45952

04-28 15:42:19.885: I/System.out(9052): cache meta: 59048f44-fb73-47f0-9aa7-d2dcb7ec8d0b and id: Product_eeb658cf-f821-4f38-8c57-9b218469bb0a_IMAGE.png

04-28 15:42:20.650: I/Facebook(9052): >

04-28 15:42:20.807: I/facebook(9052): appdata success, ready to publish to OpenGraph.



CODE:

private void saveImage(int post) {

ByteArrayOutputStream stream = new ByteArrayOutputStream();

((ProductDetails) adapter.getItem(selectedPosition)).getImage().compress(Bitmap.CompressFormat.PNG, 100, stream);

UUID imageUUID = UUID.randomUUID();

String filename = "Product_" + imageUUID + "_IMAGE.png";



final FileMetaData meta = new FileMetaData(filename);

meta.setPublic(true);



InputStream inputStream=new ByteArrayInputStream(stream.toByteArray());

mKinveyClient.file().upload(meta, inputStream, new MetaUploadProgressListener(){

@Override

public void progressChanged(MediaHttpUploader uploader) throws IOException {

}

@Override

public void onSuccess(Void result) {

Log.i("Facebook", ">");



pent.setImageUrl(getMetadata().getDownloadURL());

saveEntity();

}

@Override

public void onFailure(Throwable error) {

Log.e("Facebook", "Image save unsuccessful. ", error);

}

});

}

Hey,



Sorry for the delay in getting back to you.



This does look like a bug in the CityWatch code, I will push a fix out as soon as I can.



In the meantime, there are two changes required.



First, modify how the file is uploaded to use a `FileMetadata` object and `setPublic(true)`. Then, within the onSuccess block, set the imageURL of the entity to match the downloadURL from the upload operation.



These changes are in the saveImage() method of CityWatchEditDetailsFragment.java





FileMetaData meta = new FileMetaData(filename);

meta.setPublic(true);



InputStream inputStream=new ByteArrayInputStream(stream.toByteArray());

kinveyClient.file().upload(meta, inputStream, new MetaUploadProgressListener() {

@Override

public void progressChanged(MediaHttpUploader uploader) throws IOException {

//To change body of implemented methods use File | Settings | File Templates.

}



@Override

public void onSuccess(Void result) {

Log.i(TAG, "image saved successfully");

ent.setImageUrl(getMetadata().getDownloadURL());

saveEntity();

}



Hi,



Any update on this issue? This seems like a bug in your system as Facebook needs a URL for the image (starting with http://) and Kinvey supports only image filenames. At least the examples that are given in the tutorial use filenames and not full image URLs. Hence if there is some logic to determine the image URL after it is uploaded then please let me know.



You can verify this issue by going to the URL generated by you for Facebook scrapping. You will get this error:



'http://baas.kinvey.com/rpc/kid_VV6bhk7MNq/patadeali:add/53580edf239cd57c2104513d/patadeali:products/_objView.html' of type 'patadeali:products' is invalid because the given value 'Product_27da115c-c988-4385-b2f9-fb8ba7fb2fc8_IMAGE.png' for property 'og:image:url' could not be parsed as type 'url'.





Thanks,

Adnaan
It's on Shared
This sounds like a permissions issue. What is the current setting for your [collection-level permissions](http://devcenter.kinvey.com/android/guides/security#Collectionlevelpermissions "collection-level permissions")?
This path for the product image doesn't work as it asks for a username/password hence the image is not displayed on the facebook post. (see attachments). Please help....





http://baas.kinvey.com/rpc/kid_VV6bhk7MNq/patadeali:add/53580edf239cd57c2104513d/patadeali:products/Product_27da115c-c988-4385-b2f9-fb8ba7fb2fc8_IMAGE.png



![](https://c3409409.ssl.cf0.rackcdn.com/kinvey.vanillaforums.com/editor/ji/lsv1bon5lh16.png "")

![](https://c3409409.ssl.cf0.rackcdn.com/kinvey.vanillaforums.com/editor/ky/vl6gq9nwflhi.png "")

I think I know what the issue is. I fed the URL through the facebook debugger and got this error:



'http://baas.kinvey.com/rpc/kid_VV6bhk7MNq/patadeali:add/53580edf239cd57c2104513d/patadeali:products/_objView.html' of type 'patadeali:products' is invalid because the given value 'Product_27da115c-c988-4385-b2f9-fb8ba7fb2fc8_IMAGE.png' for property 'og:image:url' could not be parsed as type 'url'.



What is the imageURL as stored in Kinvey?? I'm just using the filename as shown in the CityWatch example:



ent.setImageURL(filename);
Is going to this link supposed to pop an authentication window asking for username and password? http://baas.kinvey.com/rpc/kid_VV6bhk7MNq/patadeali:add/53580edf239cd57c2104513d/patadeali:products/_objView.html



I'm stuck on why the og:type is beign returned as "website"
Login or Signup to post a comment