Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save alecbw/8f5a0c41d2d5c8340c5eea16cb52804a to your computer and use it in GitHub Desktop.

Select an option

Save alecbw/8f5a0c41d2d5c8340c5eea16cb52804a to your computer and use it in GitHub Desktop.

Revisions

  1. alecbw renamed this gist Jan 13, 2023. 1 changed file with 0 additions and 0 deletions.
  2. alecbw created this gist Jan 13, 2023.
    20 changes: 20 additions & 0 deletions SourceStack API Call - PHP - Jobs Advanced Filtering
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?php
    function fetch_jobs() {
    $api_key = getenv("SOURCESTACK_KEY");
    $data = array(
    "export" => "caller",
    "limit" => 100,
    "fields" => ["post_url", "company_url", "job_name", "company_name", "job_location", "hours", "department", "seniority", "remote", "tags_matched", "tag_categories", "last_indexed", "post_html"],
    "filters" => array(array("field" => "job_name", "operator" => "CONTAINS_ANY", "value" => ["SEO", "Content Market", "Digital Market"]))
    );
    $options = array(
    'http' => array(
    'header' => "Content-type: application/json\r\n" . "X-API-KEY: $api_key\r\n",
    'method' => 'POST',
    'content' => json_encode($data),
    ),
    );
    $context = stream_context_create($options);
    $response = file_get_contents("https://sourcestack-api.com/jobs", false, $context);
    return json_decode($response, true);
    }