Problem
I have a unique question that might have not been answered before.
I want to post an image to a Facebook social plugin which I have tried getting a listing of posts from two separate URLs.
First step I have tried to get this to work
I am currently trying to get a list of posts by the desired URL (Unsuccessful URL 2).
I found the following question on StackOverflow and tried adding the URL into the address bar for both websites below.
Programmatically posting Facebook comments
URL 1 works fine, but URL 2 does not.
1) Successful URL Correct JSON Returned
2) Unsuccessful URL Empty JSON Returned
Empty JSON Response
{
"https://www.change.org/p/set-armeniangenocidedoodle-on-april-24-googledoodles/u/10495296?utm_source=petition_update": {
"comments": {
"data": [
]
}
}
}
Question
Why can I not get any JSON data for URL 2 ?
Why can I not get any JSON data for URL 2 ?
Because you passed the wrong URL, by failing to properly URL-encode the parameter value.
http://graph.facebook.com/comments/?ids=https://www.change.org/p/set-armeniangenocidedoodle-on-april-24-googledoodles/u/10495296?utm_source=petition_update&utm_medium=facebook&utm_campaign=fb_comment
Let’s take that apart, shall we?
You pass one parameter ids
with the value https://www.change.org/p/set-armeniangenocidedoodle-on-april-24-googledoodles/u/10495296?utm_source=petition_update
, and then two more parameters utm_medium
with value facebook
and utm_campaign
with value fb_comment
.
The ampersand separates URL parameters. If you don’t want it to do that, but have it be part of a parameter value instead – then you need to URL-encode it properly.
(Not only the ampersand was encoded here, but the whole parameter value. You should do that whenever you put any value into a URL context.)