I'm trying to make api calls to the gfycat api but the api allways returns 400 Bad Request
I'm using Postman v7.27.1 with the following url:
https://api.gfycat.com/v1/oauth/token?grant_type=client_credentials&client_id=2_yJNBTO&client_secret=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The Documentation says the method should be POST and thats what I did.
Am I overlooking something obvious? Some header that the does not want?
Thanks in advance!
Ok my question was a bit of a quickshot but I needed to add a body with the same clientId and secret.
My body now looks like this:
{
"grant_type":"client_credentials",
"client_id":"2_yJNBTO",
"client_secret":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
Additionally the Header Content-Type had to be set to application/json
Hope this helps someone in the future :)
Related
Hello i am trying to get page level insights and post level insights in the same request but cant seem to get the syntax correct.
page id /published_posts?fields=permalink_url,created_time,message,shares,reactions.limit(0).summary(1),comments.limit(0).summary(1),insights.metric(post_reactions_by_type_total,post_impressions_unique,page_posts_impressions_organic)&since=yesterday
This is my request for now but i wanna add page insights like page_fans and page_fans_city.
How can i do that?
You are using the published_posts endpoint there already, you can not go back “up” to the page object from there. You need to rewrite the whole thing so that you use the page id itself as the basic endpoint, and then request everything else via the fields parameter. The trick is to get the syntax and nesting right …
/page-id?fields=insights.metric(page_fans,page_fans_city),published_posts{…}
should work, inside the {…} you then put all the original fields you requested from the published_posts endpoint before, so
/page-id?fields=insights.metric(page_fans,page_fans_city),published_posts{permalink_url,
created_time,…,insights.metric(post_reactions_by_type_total,post_impressions_unique,
page_posts_impressions_organic)}
And &since=yesterday then just goes at the end again, after all that.
To have the since limitation still apply on the post level, it apparently needs to be added on that “field” again, syntax similar to .metric():
?fields=…,published_posts.since(yesterday){…}
I'm working on some opt-out functionality and trying to use this endpoint:
https://graph.facebook.com/act_{ad_account_id}/usersofanyaudiences
from the docs here: https://developers.facebook.com/docs/reference/ads-api/custom-audience-targeting/#opt-out
I've been using a POST with a single ID in the body, something like this: users=[{"id":"THIS_ID_HERE"}]
I keep getting the same error:
[Error: {"message":"Unknown path components: /usersofanyaudiences","type":"OAuthException","code":2500}]
Is a POST the right method to use? Something else I might be doing wrong here?
Apologies - looks like the documentation was out of date, the proper end point is https://graph.facebook.com/act_{ad_account_id}/usersofanyaudience (singular). We have updated the documentation.
I have a question. For a rest service API designing, we can have a post method with parameters. There are four places to put my parameters.
1, we can pass it as URI template, I think if the variable is a resource, we have to put it there.
2, we can put it to the header of the request, I guess "version" is a good choice.
3, we can put it to the post request body, I mean the real parameters we want to execute the method on server.
4, we can put it as a query string, such as /sample.com/orders?id=1025.
In my mind, the post and put is not suggest to put parameters in the query string as my fourth point indicated, I cannot remember where I got that, or I might misunderstand it. Please correct me if I'm wrong, and let me know how do you think about this.
Thanks,
I think I already figureout what I asked. Here is a related post, please refer that if anymore needs it.
Do HTTP POST methods send data as a QueryString?
Thanks,
When I used Facebook's Open Graph API, I noticed that the JSONP responses generated by Facebook seemed to have an extraneous "/**/" at the beginning of each response like this:
URL:
https://graph.facebook.com/SOME_ID?method=get&pretty=0&sdk=joey&callback=FB.__globalCallbacks.f1c77f051c
Response:
/**/ FB.__globalCallbacks.f887adeec(...);
Why is this?
We added this to protect against an attack where a third party site bypasses the content-type of the response by doing: <object type="application/x-shockwave-flash" data="http://graph.facebook.com?callback=[specifically crafted flash bytes]"></object>
Google does something similar, except they use //... + \n (e.g. http://www.google.com/calendar/feeds/developer-calendar#google.com/public/full?alt=json&callback=foo)
Certainly to prevent XSSI... so you can't execute it...
http://maxime.sh/2013/02/javascript-quest-ce-que-le-xssi-et-comment-leviter/&usg=ALkJrhhjfdwBrK7kxNipOowAYacIcJm89g">Here is a french blog post about that (with google translate)
To prevent XSSI
look into the graph of facebook for more help
https://developers.facebook.com/docs/opengraph/overview/
Seems like Facebook is using a scrubber on their JSON, and it's just leaving the remaining comment holder at the beginning. Most likely leave comments there for debugging purposes, but in production the actual comments are scrubbed.
I need to receive some data from an URL every 30 seconds.
I wanted to use camel and jetty:http for it. I found one problem - to get the data from URL i need to send post variables with login and password.
How to do this?
I've been looking for an example, but i didn't found anything.
Could you help me?
And additionally question:
if i want to make some action for every 30 seconds, my code should looks like this?
from("file:src/data?noop=true&delay=30000")
.to("file:src/new");
thanks for help
if you want post data through http component, you can using form_urlencoded content type:
from("direct:postTest")
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.setHeader(Exchange.CONTENT_TYPE, constant(MediaType.APPLICATION_FORM_URLENCODED))
.setBody(simple("text=a&user=ethan"))
.to("http://someurl");