PHP ? ?? API
P粉311089279
2023-08-13 18:12:22
<p>JavaScript? ???? API? ???? ??? ??? ? ?????. </p>
<p><br /></p>
<pre class="brush:js;toolbar:false;">var ?? = {
??: "???" + MY_ACCESS_TOKEN
};
var requestParams = {
???: "POST",
??? ??: "?? ????/json",
??: ??,
????: JSON.stringify({
??: '?? {adSet(id: "' + MY_ADSET_ID + '") {insights(timeRange: {from: "2023-08-01T00:00:00Z", Until: "2023-08-10T23:59:59Z" }timeIncrement: ??) {?????? {?? ?? OfferwallImpressions OfferwallAverageRank ??}}}}? ?????.
})
var response = UrlFetchApp.fetch(MY_API_ENDPOINT, requestParams);
var data = JSON.parse(response);</pre>
<p><br /></p>
<p>??? PHP? ????? ?? API?? ? ??? ????. ?? ? ?????? </p><p>
my_curl()? ???? API?? $MY_ACCESS_TOKEN? ???? ??? ?????. </p>
<pre class="brush:php;toolbar:false;">$postdata = json_encode('query: query {adSet(id: "' . $MY_ADSET_ID . '") {insights(timeRange: {from: "2023 -08-01T00:00:00Z", ??: "2023-08-10T23:59:59Z"} timeIncrement: DAILY) {????? ??? {?? ?? OfferwallImpressions OfferwallAverageRank ??}}}}');
$?? = $MY_API_ENDPOINT;
$?? = ??(
"??? ??: ??????/json",
"?? ??: ??? " .
$postdata
);
$data = my_curl($endpoint, $headers);
var_dump($data);
?? my_curl($endpoint, $headers) {
$ch = ?_???();
?_setopt($ch, CURLOPT_URL, $endpoint);
?_setopt($ch, CURLOPT_POST, 1);
?_setopt($ch, CURLOPT_HTTPHEADER, $headers);
?_setopt($ch, CURLOPT_HEADER, false);
cur_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = ?_exec($ch);
?_??($ch);
$json = json_decode($server_output, ?);
??($json);
}
</pre>
<p><br /></p>
json_encode? ??? ?? ???? ?? JSON?? ???? ?? ???? ??? ???? ???. ??? ?? ???? ???? $headers ??? ??? ??? ???? ???? ????. cURL ??? JSON?? ???? ??? ???? ????? ??? CURLOPT_POSTFIELDS ??? ???? API? ??? ???? ??? ? ??? ????.
????
?? +0
P粉311089279