rashgang Posted September 16, 2013 Share Posted September 16, 2013 Hi All, Please anyone help me to write api for a portal sites. I am new to api services. Please anyone tell me how to use REST. Also i would like to know what is the difference between rest and soap. Why should not use soap ?. Please show me some examples to write api for a site. is it safe to write api in rest ? Link to comment https://forums.phpfreaks.com/topic/282189-how-to-write-api-for-my-site/ Share on other sites More sharing options...
requinix Posted September 16, 2013 Share Posted September 16, 2013 - Use a few other APIs to learn how other people do them. - Google "REST API" and read the results. - REST is purely HTTP headers, SOAP is regular HTTP with lots (lots) of XML, but sometimes it's easier to code for than REST (like in other languages besides PHP). - Showing examples of APIs is crazy. There's too much to post. Like I said: Google it. - Yes, a REST API is totally safe. I don't know why you would think it isn't. Link to comment https://forums.phpfreaks.com/topic/282189-how-to-write-api-for-my-site/#findComment-1449740 Share on other sites More sharing options...
priyankagound Posted September 18, 2013 Share Posted September 18, 2013 Some Facebook widgets do use iframes. Twitter uses javascript that most likely interacts with Ajax scripts on their server and returns HTML code to output to an HTML element that is part of their widget embed code. Either way works. Example based on Javascript and PHP (no Ajax): Embed Code <script type="text/javascript">width = 527;height = 95;</script><script type="text/javascript" src="http://www.mysite.com/widget.js"></script> widget.js document.write('<iframe scrolling="no" frameborder="0" width="' + width + '" height="' + height + '" src="http://www.mysite.com/showdata.php?height=' + height + '&width=' + width + '" style="border: 1px solid #6c82b5;"></iframe>'); And showdata.php could be any PHP script you want to display any data you want. You can give your users some flexibility about design and colors by passing variables through the javascript as you see me doing here. Link to comment https://forums.phpfreaks.com/topic/282189-how-to-write-api-for-my-site/#findComment-1450030 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.