Jump to content

Pinging an API and using the XML that is sent back.


lamajlooc

Recommended Posts

This is probably a dumb question, but I'm getting stumped.

 

I'm using AdBrite's video API that allows you to add a video to their service dynamically and sends back XML data including the code you include on your blog or wherever.

 

Specifically, here is the problem I'm solving:

1) Presently a user adds a video to our system using our web form, inputting all the needed data (title, description, tags, etc.) and uploads the file.

2) We then manually add the data for that video to AdBrite's system so we can serve ads on the videos on our site.

 

This is obviously cumbersome and will only grow more so as more users join the site (hopefully).

 

AdBrite is nice enough to have provided an API so that the process can be automated.

 

My problem is that I don't know how to "ping" their API and receive and store the code they send back via and XML file.  I've URI-encoded all the parameters they ask for and I've tested the URI using header();.  It works and I get the XML code, but it's just posted to the browser window, not my program, obviously.

 

My question is how I send the URI-encoded data to their API from within my program without leaving the program and how I retrieve the data they send back.

 

They're less than helpful on their site.  Here's what they say:

Want a faster way to register your videos with Black Label Ads? Does your video site automate video uploading? If so, then you might be interested in using our API. Simply ping our API at https://www.adbrite.com/video/add_video_api.php with the required parameters, and if everything's OK, we'll send back an XML file with the appropriate code to put on your site.

 

Example URI

 

https://www.adbrite.com/video/add_video_api.php?username=YOUR_USERNAME&password=YOUR_PASSWORD&category_id=VALID_ID&v_rating=VALID_RATING&v_flv_url=VALID_URL&v_title=TITLE_STRING&v_description=DESCRIPTION_STRING&v_override_clickback={1,0}&v_page_url=VALID_URL&v_override_playback={1,0}&v_autostart={1,0}&v_preroll_image_url=VALID_URL&v_show_play_button_not={1,0}&v_show_preroll_image={1,0}&v_embed_override_global={1,0}&v_show_preroll_image_embed={1,0}&v_preroll_image_url_embed=VALID_URL&v_show_play_button_embed_not={1,0}&v_width=POSITIVE_INTEGER&v_height=POSITIVE_INTEGER&v_show_ads={1,0}&keywords=KEYWORDS_STRING

 

https://www.adbrite.com/video/add_video_api.php?username=YOUR_USERNAME&password=YOUR_PASSWORD&category_id=412&v_rating=pg&v_flv_url=http%3A//www.mywebserver.com/video%3Fid%3Ds177Ys41t&v_title=My%20Summer%20Vacation&v_description=This%20is%20what%20I%20did%20last%20summer.%20What%20a%20trip%21&v_override_clickback=1&v_page_url=http%3A//www.mywebserver.com/pages%3Fpid%3D%20wps177Ys41t&v_override_playback=1&v_autostart=0&v_preroll_image_url=http%3A//www.mywebserver.com/images%3Fid%3Dwis177Ys41t&v_show_play_button_not=0&v_show_preroll_image=1&v_embed_override_global=1&v_show_preroll_image_embed=1&v_preroll_image_url_embed=http%3A//www.mywebserver.com/images%3Fid%3Dwis177Ys41t&v_show_play_button_embed_not=0&v_width=468&v_height=400&v_show_ads=1&keywords=summer%0Avacation%0Asummer%20vacation%0Atravel%0A

Expected Return Values

 

The general format of the return is an xml document with the following structure:

 

  <addvideo>

      <type><!-- error | success  --></type>

      <message><!-- any message --></message>

      <!-- more message nodes -->

  </addvideo>

 

The specific return values (as of now) are:

 

  <addvideo>

      <type>error</type>

      <message>User must save their global settings before using the api.</message>

  </addvideo>

 

  <addvideo>

      <type>error</type>

      <message>Invalid username or password</message>

  </addvideo>

 

  <addvideo>

      <type>success</type>

      <message><![CDATA[<!-- html code for your page. -->]]></message>

      <message><!-- video_id --></message>

  </addvideo>

 

The URI being passed to them is fine, and they return the third set of XML data...what do I do now?

 

Thanks in advance.

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.