Reputation: 333
I have a http_build_query array and file_get_contents that looks like this:
$optionValues = http_build_query( array(
'leadcomm' => getVariable('LEADCOMM'),
'CCID' => getVariable('CCID'),
'QTR' => getVariable('QTR'),
'CLK' => getVariable('CLK'),
'dck' => getVariable('DCK'),
'bal_one' => getVariable('BAL_ONE'),
'product' => getVariable('PRODUCT'),
'prop_st' => getVariable('PROP_ST'),
'cred_grade' => getVariable('CRED_GRADE'),
'prop_zip' => getVariable('PROP_ZIP'),
'prop_desc' => getVariable('PROP_DESC'),
'spec_home' => getVariable('SPEC_HOME'),
'purchase_contract' => getVariable('PURCHASE_CONTRACT'),
'est_val' => getVariable('EST_VAL'),
'down_pmt' => getVariable('DOWN_PMT'),
'loan_type' => getVariable('LOAN_TYPE'),
'buy_timeframe' => getVariable('BUY_TIMEFRAME'),
'agent_found' => getVariable('AGENT_FOUND'),
'va_status' => getVariable('VA_STATUS'),
'income' => getVariable('INCOME'),
'annual_verifiable_income' => getVariable('ANNUAL_VERIFIABLE_INCOME'),
'fha_bank_foreclosure' => getVariable('FHA_BANK_FORECLOSURE'),
'num_mortgage_lates' => getVariable('NUM_MORTGAGE_LATES'),
'email' => getVariable('EMAIL'),
'fname' => getVariable('FNAME'),
'lname' => getVariable('LNAME'),
'address' => getVariable('ADDRESS'),
'city' => getVariable('CITY'),
'state' => getVariable('STATE'),
'zip' => getVariable('ZIP'),
'pri_phon' => getVariable('PRI_PHON'),
'sec_phon' => getVariable('SEC_PHON'),
'capture_method' => getVariable('CAPTURE_METHOD'),
'aid' => getVariable('AID'),
'srlp' => getVariable('SRLP'),
'scid' => getVariable('SCID'),
'buyer_id' => getVariable('BUYER_ID'),
'cid' => getVariable('CID'),
'ppcid' => getVariable('PPCID')
)
);
$url = 'http://api.example.com/import-lead-data.php';
$options['http'] = array(
'method' => "POST",
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $optionValues,
);
$context = stream_context_create($options);
$result = file_get_contents($url, NULL, $context);
I need to check if $results returns a numeric value. If it does, I need to set a new variable ($lead_id) to equal $results, pass $lead_id through another http_build_query array and finally do another file_get_contents $results. The code above works fine. The second part of the code is where I need some assistance. This is what I have for the second part of my code:
if (is_numberic($result)) {
$lead_id(isset($results));
};
$leadValues = http_build_query( array(
'lead_id' => "LEAD_ID"
)
);
$leadurl = 'http://api.bankradar.com/import-lead-response.php';
$leadoptions['http'] = array(
'method' => "POST",
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $leadValues,
);
$leadcontext = stream_context_create($leadoptions);
$leadResult = file_get_contents($leadurl, NULL, $leadcontext);
I think my problem is with the isset part of the code but I'm not sure.
Upvotes: 0
Views: 134
Reputation: 553
You are calling $lead_id as a function. Just change
$lead_id(isset($results));
to
$lead_id = $results;
Upvotes: 0
Reputation: 5000
you put
if (is_numberic($result)) {
should be
if (is_numeric($result)) {
But, i use this way
if (ctype_digit($result)) {
that way it can only containt digits, no decimals or any other characters... not sure if thats what your after
Upvotes: 1