I implemented the following API call:
$secret = 'my_secret_key';
# Required parameters
$params = array(
'unique_user_id'=> $my_nickname,
'date_of_birth'=> $my_dob,
'email'=> $my_email,
'gender'=> $my_gender,
'zip_code'=> $my_zip,
'ip_address'=> $my_ip,
'limit'=> 3,
'basic'=> 1,
);
$params = http_build_query($params);
$opts = array(
'http'=> array(
'method'=> "GET",
'header'=> "X-Api-Key: $secret",
'ignore_errors' => true,
)
);
$url = 'https://www.target-server.com/suppliers_api/works/user';
$url = $url . '?' . $params;
$context = stream_context_create($opts);
/* Sends an http request with additional headers shown above */
$fp = fopen($url, 'r', false, $context);
# Output all data from the response
fpassthru($fp);
fclose($fp);
?>
I got the following output:
{ "messages": [], "status": "success", "surveys": [ { "project_id": 12345678, "name": "Study", "study_type": 1, "cpi": "0.42", "remaining_completes": 104, "conversion_rate": "0.00", "loi": 15, "country": "US", "survey_groups_ids": [], "platform_types": [ "desktop", "ios_tablet", "android_phone", "ios_phone", "android_tablet", "android_kindle", "ios_tablet" ], "match_to_qualify": true, "delay_crediting": false, "tentative_payout": false, "order": { "loi": 15, "ir": 85 }, "is_pmp": false, "entry_link": "https://www.target-servet.com?si=XXX&ssi=SUBID&unique_user_id=user4&hmac=checksum_calculated&offer_id=12345678", "score": null } ], "user_account_status": "good", "quality_score_status": "good" }
I would like PHP to extract the following fields and format them as follows:
Project ID: 12345678
URL: https://www.target-server.com?si=XXX&ssi=SUBID&unique_user_id=user4&hmac=checksum_calculated&offer_id=12345678
CPI: 0.42
LOI: 15
Will you please help me to edit my PHP code in order to select ONLY CERTAIN FIELDS in certain format? Need only fields "entry_link", "project_id", "cpi", "loi".