Tildelt

php JSON to array function with simple curl data pull

I need a PHP function getCurrentOptionLink($symbol)

It will be passed an option symbol such as CREE171215P00035000

It will form a URL as [url removed, login to view][symbol]

e.g.: [url removed, login to view]

It will get the returned content using php's curl function ([url removed, login to view]) or other standard library for getting https content

The returned content is JSON

e.g.:

{"optionChain":{"result":[{"underlyingSymbol":"CREE171215P00035000","expirationDates":[],"strikes":[],"hasMiniOptions":false,"quote":{"language":"en-US","quoteType":"OPTION","currency":"USD","fiftyTwoWeekHighChangePercent":0.0,"fiftyTwoWeekLow":1.73,"fiftyTwoWeekHigh":1.76,"priceHint":2,"tradeable":false,"regularMarketPrice":1.76,"regularMarketTime":1510343151,"regularMarketChange":-0.01999998,"regularMarketOpen":1.73,"regularMarketDayHigh":1.76,"regularMarketDayLow":1.73,"regularMarketVolume":9,"sourceInterval":15,"exchangeTimezoneName":"America/New_York","exchangeTimezoneShortName":"EST","gmtOffSetMilliseconds":-18000000,"exchange":"OPR","marketState":"CLOSED","shortName":"CREE Dec 2017 35.000 put","strike":35.0,"underlyingSymbol":"CREE","openInterest":820,"expireDate":1513296000,"regularMarketChangePercent":-1.1235945,"regularMarketPreviousClose":1.78,"bid":1.73,"ask":1.88,"fullExchangeName":"OPR","fiftyTwoWeekLowChange":0.029999971,"fiftyTwoWeekLowChangePercent":0.017341023,"fiftyTwoWeekHighChange":0.0,"exchangeDataDelayedBy":20,"market":"us24_market","symbol":"CREE171215P00035000"},"options":[]}],"error":null}}

the function will convert the JSON to a php data structure $optionChain and return $optionChain['optionChain']['result'].

NOTE the first two levels (optionChain and result) are to be stripped.

[url removed, login to view] should be printed (echo or error_log) if set.

Such that $option = getCurrentOptionLink('CREE171215P00035000');

would have:

echo $option['quote']['underlyingSymbol'];

print "CREE"

Færdigheder: CSS, HTML, PHP, Web Design, WordPress

Se mere: php get json response from url, how to fetch data using curl in php, how to get json response using curl in php, php curl post json response, php get json data from api, how to get json data from url using php, php curl json post, how to fetch data from api in php, php function login curl, php simple quiz data mysql, simple edit data script php, simple demo program passing array function program, php parse html curl data, php function post curl type, array function php

Om arbejdsgiveren:
( 0 bedømmelser ) Toronto, Canada

Projekt-ID: #15619656

Tildelt til:

spryox

Hired by the Employer

$15 CAD in 3 dage
(62 bedømmelser)
4.8