> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# الحصول على حملة

> اقرأ حالة حملة Google Ads وميزانيتها اليومية، ومراجعة Google لكل إعلان أو أصل فيها.

احصل على حملة Google Ads أنشأتها عبر Ayrshare: اسمها وحالتها وميزانيتها اليومية ومراجعة Google لكل إعلان من إعلاناتها.

## معاملات الترويسة

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## معاملات المسار

**id** `string` *required*

قيمة `campaignId` التي أُعيدت عند إنشاء الحملة.

## الاستجابة

| الحقل | ما يحتويه |
| - | - |
| `campaignId` | معرّف الحملة |
| `name` | اسم الحملة |
| `campaignStatus` | `active` أو `paused` |
| `platformStatus` | حالة Google الخاصة: `ENABLED` أو `PAUSED` أو `REMOVED` للحملة المحذوفة في Google Ads. تحتفظ الحملة المُزالة بآخر قيمة `campaignStatus` عيّنتها عبر Ayrshare |
| `budget` | الميزانية اليومية: `amount` و`currency` (عملة حساب الإعلانات) و`type` (`daily`) |
| `ads` | مراجعة Google لكل إعلان (Search) أو أصل (Performance Max). راجع [مراجعة الإعلانات](#ad-review) |

## مراجعة الإعلانات

يراجع Google كل إعلان جديد وفق سياساته الإعلانية، عادةً خلال يوم عمل واحد. يحتوي كل صف في `ads` على:

| الحقل | ما يحتويه |
| - | - |
| `adId` | معرّف الإعلان، كما يُعيده الإنشاء |
| `approvalStatus` | قرار Google: `APPROVED` أو `APPROVED_LIMITED` (يُعرض مع قيود، على سبيل المثال ليس في بعض البلدان) أو `AREA_OF_INTEREST_ONLY` أو `DISAPPROVED`. وإلى أن يتخذ Google قراره، يحمل قيمة أخرى، مثل `UNKNOWN` أو `UNSPECIFIED` |
| `reviewStatus` | المرحلة التي بلغتها المراجعة، على سبيل المثال `REVIEW_IN_PROGRESS` أو `REVIEWED` |
| `policyTopics` | السياسات التي تقف وراء القيد أو الرفض: `[{ "topic": "ALCOHOL", "type": "PROHIBITED" }]` |

الإعلان المرفوض لا يُعرض. عدّله في Google Ads، أو أنشئ حملة جديدة بنص متوافق مع السياسات. ويُستبعد `ads` عندما يتعذّر قراءة مراجعة Google في تلك اللحظة، أو عندما تستغرق أكثر من بضع ثوانٍ؛ اقرأ الحملة مجددًا لاحقًا.

يتحقق Ayrshare أيضًا كل ليلة من كل مراجعة، ويرسل webhook من نوع `ads` مع `type: "reviewChanged"` عندما يتغير قرار Google. راجع [إجراء Ads](https://www.ayrshare.com/docs/apis/webhooks/actions.md#ads-action).

## مراجعة الأصول

يراجع Google كل أصل من أصول حملة Performance Max على حدة. يحتوي `ads` على صف واحد لكل أصل، بالحقول نفسها الموجودة في [مراجعة الإعلانات](#ad-review) بالإضافة إلى:

| الحقل | ما يحتويه |
| - | - |
| `adId` | مفتاح الأصل في هذه الحملة: `asset:<assetGroupId>~<assetId>~<fieldType>`، أو `asset:<campaignId>~<assetId>~<fieldType>` لأصل العلامة التجارية |
| `assetId` | معرّف Google للأصل |
| `fieldType` | مكان استخدامه، على سبيل المثال `HEADLINE` أو `MARKETING_IMAGE` أو `SQUARE_MARKETING_IMAGE` أو `BUSINESS_NAME` أو `LOGO` |
| `primaryStatus` | ما إذا كان يمكن عرضه، على سبيل المثال `ELIGIBLE` أو `NOT_ELIGIBLE` |

اسم النشاط التجاري والشعارات والشعارات الأفقية أصول للعلامة التجارية، مرتبطة بالحملة وليس بمجموعة الأصول. ولها صف هنا أيضًا، بعد صفوف مجموعة الأصول، ومفتاحه معرّف الحملة: `asset:<campaignId>~<assetId>~<fieldType>`، حيث تكون قيمة `fieldType` هي `BUSINESS_NAME` أو `LOGO` أو `LANDSCAPE_LOGO`.

## الأخطاء

| الرمز | متى |
| - | - |
| `400` | الحملة لا تخصك، أو غير موجودة، أو لم تعد في حساب Google Ads. وكذلك عندما لا يستطيع مستخدم Google الذي ربطته الوصول إلى حساب الإعلانات، أو عندما أُلغي الوصول إلى Google Ads. |
| `370` | تعذّر على Google إكمال الطلب. حاول مرة أخرى. |

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/google/campaigns/21534567890"
```

```javascript JavaScript theme={"system"}
const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${API_KEY}`
  }
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);
```

```python Python theme={"system"}
import requests

headers = {
    "Authorization": "Bearer API_KEY",
}

r = requests.get("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", headers=headers)

print(r.json())
```

```php PHP theme={"system"}
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns/21534567890",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer API_KEY"
    ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error: " . $err;
} else {
    echo $response;
}
?>
```

```csharp C# theme={"system"}
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");

        var response = await client.GetAsync("https://api.ayrshare.com/api/ads/google/campaigns/21534567890");
        var content = await response.Content.ReadAsStringAsync();

        Console.WriteLine(content);
    }
}
```

```go Go theme={"system"}
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/google/campaigns/21534567890", nil)
    req.Header.Add("Authorization", "Bearer API_KEY")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={"system"}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class GetCampaign {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns/21534567890"))
            .header("Authorization", "Bearer API_KEY")
            .GET()
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

```ruby Ruby theme={"system"}
require 'net/http'
require 'uri'

uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns/21534567890')

request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer API_KEY'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

puts response.body
```

```json 200: Search Campaign theme={"system"}
{
  "status": "success",
  "platform": "google",
  "campaignId": "21534567890",
  "name": "Fall sale",
  "campaignStatus": "active",
  "platformStatus": "ENABLED",
  "budget": { "amount": 25, "currency": "USD", "type": "daily" },
  "ads": [
    {
      "adId": "71234567890",
      "approvalStatus": "APPROVED_LIMITED",
      "reviewStatus": "REVIEWED",
      "policyTopics": [{ "topic": "ALCOHOL", "type": "LIMITED" }]
    }
  ]
}
```

```json 200: Performance Max Campaign theme={"system"}
{
  "status": "success",
  "platform": "google",
  "campaignId": "21534567891",
  "name": "Fall sale PMax",
  "campaignStatus": "paused",
  "platformStatus": "PAUSED",
  "budget": { "amount": 40, "currency": "USD", "type": "daily" },
  "ads": [
    {
      "adId": "asset:6512345678~31234567890~HEADLINE",
      "assetId": "31234567890",
      "fieldType": "HEADLINE",
      "primaryStatus": "ELIGIBLE",
      "approvalStatus": "APPROVED",
      "reviewStatus": "REVIEWED",
      "policyTopics": []
    }
  ]
}
```

```json 400: Not Found theme={"system"}
{
  "action": "ads",
  "status": "error",
  "code": 400,
  "message": "Campaign not found or you are not authorized to access it."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.