diff options
| author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-09-22 15:37:57 +0800 |
|---|---|---|
| committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-09-22 15:37:57 +0800 |
| commit | 1fa2c1228f279b7e298b6e1e3037924717539211 (patch) | |
| tree | 8a35f4afd0c732155973eb58ae65fbbf8a081fc7 /request.c | |
| parent | 77f8f4a9c3f6a83f965fad7cc6010476f784584d (diff) | |
Merge request_gettoken
Diffstat (limited to 'request.c')
| -rw-r--r-- | request.c | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/request.c b/request.c deleted file mode 100644 index 099491b..0000000 --- a/request.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "request.h" -#include "shopify.h" - -extern inline void request_gettoken(const char *, const char *, const char *, - const char *, char **); - -void shopify_graphql(const char *query, const struct shopify_session *session, - char **json) -{ - CURL *curl = curl_easy_init(); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, append); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, json); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, query); - - static const char *url_tmpl - = "https://%s/admin/api/2022-07/graphql.json"; - char url[strlen(url_tmpl) - strlen("%s") + strlen(session->shop) + 1]; - sprintf(url, url_tmpl, session->shop); - curl_easy_setopt(curl, CURLOPT_URL, url); - - static const char *hdr_tmpl = "X-Shopify-Access-Token: %s"; - char header[strlen(hdr_tmpl) - strlen("%s") - + strlen(session->access_token) + 1]; - sprintf(header, hdr_tmpl, session->access_token); - - struct curl_slist *list = NULL; - list = curl_slist_append(list, header); - list = curl_slist_append(list, "Content-Type: application/graphql"); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); - - curl_easy_perform(curl); - curl_slist_free_all(list); - curl_easy_cleanup(curl); -} |