lse123
May 21, 2014, 11:31am
1
I am a reader of “PHP Master: Write Cutting-edge Code” - Rest WSs section - ch.3 I have some Qs…
i must have the folder of ch.3: /rest/ to root of localhost? or the contents of /rest/ directly to the root?
so with below code i must echo the $events? and this snippet above can be in other domain than the Rest web service?
Rest code to run the Rest web service like p.118(“PHP Master: Write Cutting-edge Code” - Rest WSs section - ch.3):
// http://localhost/rest/events OR http://localhost/events ___ what’s the correct in curl_init? Also in what file put below [p.118] and where
$ch = curl_init('http://localhost/rest/events');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$events = json_decode($response,1);
index.php is called implicitly in REST ws?
lse123
May 21, 2014, 11:59am
2
I made it work … so just this: index.php is called implicitly in REST ws?
lse123
May 22, 2014, 11:19am
3
Also in yahoo search using // got below…
$url = "http://yboss.yahooapis.com/ysearch/news,web,images";
$args = array();
$args["q"] = "yahoo";
$args["format"] = "json";
$consumer = new OAuthConsumer($cc_key, $cc_secret);
$request = OAuthRequest::from_consumer_and_token($consumer, NULL,"GET", $url, $args);
$request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL);
$url = sprintf("%s?%s", $url, OAuthUtil::build_http_query($args));
$ch = curl_init();
$headers = array($request->to_header());
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$rsp = curl_exec($ch);
$results = json_decode($rsp);
print_r($results);
how access below result in php?
stdClass Object ( [bossresponse] => stdClass Object ( [responsecode] => 200 [images] => stdClass Object ( [start] => 0 [count] => 35 [totalresults] => 1180000 [results] => Array ( [0] => stdClass Object ( [refererurl] => http://www.mondoinformatico.info/yahoo-cambia-faccia-ecco-la-nuova-grafica-online-dalle-1600_post-26867.html [refererclickurl] => http://www.mondoinformatico.info/yahoo-cambia-faccia-ecco-la-nuova-grafica-online-dalle-1600_post-26867.html => http://www.mondoinformatico.info/foto/20091126yahoo.bmp [clickurl] => http://www.mondoinformatico.info/foto/20091126yahoo.bmp [title] => … su Facebook, Yahoo! Mail (oppure GMail o AolMail), Answer, ecc [format] => bmp [size] => 3000.1KB [height] => 800 [width] => 1280 [thumbnailheight] => 100 [thumbnailwidth] => 160 [thumbnailurl] => http://ts4.mm.bing.net/th?id=HN.608049481005862575&pid=15.1&H=100&W=160 ) [1] => stdClass Object ( [refererurl] => http://www.websiteoptimization.com/speed/tweak/css-sprites/ [refererclickurl] => http://www.websiteoptimization.com/speed/tweak/css-sprites/ => http://www.websiteoptimization.com/speed/tweak/css-sprites/yahoo-sprites.jpg [clickurl] => http://www.websiteoptimization.com/speed/tweak/css-sprites/yahoo-sprites.jpg [title] => CSS Sprites: How Yahoo.com and AOL.com Improve Web Performance [format] => jpeg [size] => 115.1KB [height] => 630 [width] => 1017 [thumbnailheight] => 98 [thumbnailwidth] => 160 [thumbnailurl] => http://ts2.mm.bing.net/th?id=HN.607990906246793053&pid=15.1&H=98&W=160 ) [2] => stdClass Object ( [refererurl] => http://im.about.com/od/joiningtheimworld/ss/yahoo-messenger-web.htm [refererclickurl] => http://im.about.com/od/joiningtheimworld/ss/yahoo-messenger-web.htm => http://0.tqn.com/d/im/1/0/A/E/-/-/yahoo-messenger-web.jpg [clickurl] => http://0.tqn.com/d/im/1/0/A/E/-/-/yahoo-messenger-web.jpg [title] => Yahoo Web Messenger: IM Without Downloading Yahoo Messenger [format] => jpeg [size] => 94.1KB [height] => 800 [width] => 1280 [thumbnailheight] => 100 [thumbnailwidth] => 160 [thumbnailurl] => http://ts4.mm.bing.net/th?id=HN.608021177174131619&pid=15.1&H=100&W=160 ) [3] => stdClass Object ( [refererurl] => http://mercadoemvista.wordpress.com/tag/yahoo/ [refererclickurl] => http://mercadoemvista.wordpress.com/tag/yahoo/ => http://mercadoemvista.files.wordpress.com/2011/09/yahoo.jpg [clickurl] => http://mercadoemvista.files.wordpress.com/2011/09/yahoo.jpg [title] => Yahoo Brasil irΓ΅ remunerar usuΓ΅rios que colaborarem com conteΓΊdo [format] => jpeg [size] => 332.3KB [height] => 900 [width] => 3212 [thumbnailheight] => 44 [thumbnailwidth] => 160 [thumbnailurl] => http://ts2.mm.bing.net/th?id=HN.608032387034580773&pid=15.1&H=44&W=160 ) [4] => stdClass Object ( [refererurl] => http://googlediscovery.com/2010/09/16/yahoo-apresenta-novo-yahoo-mail-beta-e-anuncia-outras-novidades/ [refererclickurl] => http://googlediscovery.com/2010/09/16/yahoo-apresenta-novo-yahoo-mail-beta-e-anuncia-outras-novidades/ => http://googlediscovery.com/wp-content/uploads/Yahoo-Mail-Beta-with-IM-Final2.png [clickurl] => http://googlediscovery.com/wp-content/uploads/Yahoo-Mail-Beta-with-IM-Final2.png [title] => Yahoo! apresenta novo Yahoo! Mail Beta e anuncia outras novidades [format] => png [size] => 359.7KB [height] => 662 [width] => 1023 [thumbnailheight] => 103 [thumbnailwidth] => 160 [thumbnailurl] => http://ts3.mm.bing.net/th?id=HN.607995304286815434&pid=15.1&H=103&W=160 ) [5] => stdClass Object ( [refererurl] => http://voaburmese.wordpress.com/2010/08/26/burmas-first-web-portal-yatarnarpon/ [refererclickurl] =>
lse123
May 22, 2014, 12:16pm
4