Jump to content

how to write api for my site?


rashgang
Go to solution Solved by requinix,

Recommended Posts

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
Share on other sites

  • Solution

- 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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.