{"id":175,"date":"2016-06-17T15:04:47","date_gmt":"2016-06-17T15:04:47","guid":{"rendered":"http:\/\/symbioticindia.in\/docu\/?p=175"},"modified":"2016-06-17T15:06:53","modified_gmt":"2016-06-17T15:06:53","slug":"175","status":"publish","type":"post","link":"http:\/\/symbioticindia.in\/docu\/2016\/06\/17\/175\/","title":{"rendered":"PHP code to access php webservice"},"content":{"rendered":"<p>&lt;?php<\/p>\n<p>function post_to_url($url, $data) {<br \/>\n$fields = &#8221;;<br \/>\nforeach ($data as $key =&gt; $value) {<br \/>\n$fields .= $key . &#8216;=&#8217; . $value . &#8216;&amp;&#8217;;<br \/>\n}<br \/>\nrtrim($fields, &#8216;&amp;&#8217;);<\/p>\n<p>$post = curl_init();<\/p>\n<p>curl_setopt($post, CURLOPT_URL, $url);<br \/>\ncurl_setopt($post, CURLOPT_POST, count($data));<br \/>\ncurl_setopt($post, CURLOPT_POSTFIELDS, $fields);<br \/>\ncurl_setopt($post, CURLOPT_RETURNTRANSFER, 1);<\/p>\n<p>$result = curl_exec($post);<br \/>\ncurl_close($post);<br \/>\nreturn $result;<br \/>\n}<\/p>\n<p>$data = array(&#8220;mobile1&#8243;=&gt;&#8221;1111111&#8243;,&#8221;mobile2&#8243;=&gt;&#8221;123456789&#8221;,<br \/>\n&#8220;fname&#8221;=&gt;&#8221;Bill&#8221;,&#8221;lname&#8221;=&gt;&#8221;Clinton&#8221;,&#8221;dstatus&#8221;=&gt;&#8221;wait&#8221;,&#8221;rstatus&#8221;=&gt;&#8221;old&#8221;,<br \/>\n&#8220;server_ipadr&#8221;=&gt;&#8221;192.168.1.120&#8243;,&#8221;trans_id&#8221;=&gt;&#8221;5&#8243;,&#8221;time_of_meet&#8221;=&gt;&#8221;15min&#8221;,&#8221;server_id&#8221;=&gt;&#8221;101&#8243;);<\/p>\n<p>$surl = &#8216;http:\/\/192.168.1.120\/test1\/signup1.php&#8217;;<br \/>\necho post_to_url($surl, $data);<br \/>\n?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php function post_to_url($url, $data) { $fields = &#8221;; foreach ($data as $key =&gt; $value) { $fields .= $key . &#8216;=&#8217; . $value . &#8216;&amp;&#8217;; } rtrim($fields, &#8216;&amp;&#8217;); $post = curl_init(); curl_setopt($post, CURLOPT_URL, $url); curl_setopt($post, CURLOPT_POST, count($data)); curl_setopt($post, CURLOPT_POSTFIELDS, $fields); curl_setopt($post, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($post); curl_close($post); return $result; } $data = array(&#8220;mobile1&#8243;=&gt;&#8221;1111111&#8243;,&#8221;mobile2&#8243;=&gt;&#8221;123456789&#8221;, &#8220;fname&#8221;=&gt;&#8221;Bill&#8221;,&#8221;lname&#8221;=&gt;&#8221;Clinton&#8221;,&#8221;dstatus&#8221;=&gt;&#8221;wait&#8221;,&#8221;rstatus&#8221;=&gt;&#8221;old&#8221;, &#8220;server_ipadr&#8221;=&gt;&#8221;192.168.1.120&#8243;,&#8221;trans_id&#8221;=&gt;&#8221;5&#8243;,&#8221;time_of_meet&#8221;=&gt;&#8221;15min&#8221;,&#8221;server_id&#8221;=&gt;&#8221;101&#8243;); $surl ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"http:\/\/symbioticindia.in\/docu\/2016\/06\/17\/175\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":2,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":177,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/175\/revisions\/177"}],"wp:attachment":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}