virla
Posts: 4
Joined: Wed Jun 08, 2011 8:59 am

Postby virla » Thu Jun 09, 2011 6:30 am

Dear Sir,
I have some question related to Awasu API interface


1] If I require Http responce in my Application which is written in C# than
how will i get it ,If possible please pprovide me some example code for
that.

2] I want to create C# base channel hook by that My application directly et
new feed data so please guide me on that and if possible provide me example
code for that.


3] How channel hook will inform or notify to my application written in c#
regarding new feed available on subscribed channel.

User avatar
support
Site Admin
Posts: 2925
Joined: Fri Feb 07, 2003 8:48 am
Location: Melbourne, Australia
Contact:

Postby support » Fri Jun 10, 2011 10:10 am

virla wrote:1] If I require Http responce in my Application which is written in C# than
how will i get it ,If possible please pprovide me some example code for
that.

When you send a HTTP request, you will get an HTTP response. How to read this response is C#-specific and nothing to do with Awasu. We're not C# people here so you probably need to get help elsewhere for this one.

virla wrote:2] I want to create C# base channel hook by that My application directly et
new feed data so please guide me on that and if possible provide me example
code for that.

The LogChannelActivity sample hook I mentioned elsewhere contains everything you need to write your own hook. Unfortunately, we don't have any samples in C#.

virla wrote:3] How channel hook will inform or notify to my application written in c#
regarding new feed available on subscribed channel.

When your channel hook script gets called, it will be passed all the details of the newly-received content. How your script passes it on to your main application is entirely up to you.

User avatar
kevotheclone
Posts: 231
Joined: Mon Sep 08, 2008 3:16 pm
Location: Elk Grove, California

Postby kevotheclone » Fri Jun 10, 2011 8:02 pm

virla wrote:1] If I require Http responce in my Application which is written in C# than how will i get it ,If possible please pprovide me some example code for that.

To make HTTP requests (and receive HTTP responses) in C# you can use the System.Net.WebClient Class.
This page contains examples: http://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.80).aspx

virla wrote:2] I want to create C# base channel hook by that My application directly et new feed data so please guide me on that and if possible provide me example code for that.

This is a bare-bones example that really doesn't do anything useful, It's using the ini-parser library to parse the INI file that Awasu provides. It's coded to be called from Awasu "ConsolidatedNewFeedItems" event, so it's looking for INI file sections that start with "NewFeedItem"

Code: Select all

using IniParser;
using System;
using System.Text;

namespace AwasuExtensions
{
    class AwasuChannelHook
    {
        enum ExitCode : int
        {
            Success = 0,
            MissingArguments = 1,
            InvalidIniFile = 2,
            UnknownError = 10
        };
       
        static void Main(string[] args)
        {
            // Exit with error message if an INI file path wasn't passed
            if (args.Length == 0)
            {
                System.Console.WriteLine("Error: INI file must be passed as first argument.");
                System.Environment.Exit((int)ExitCode.MissingArguments);
            }

            FileIniDataParser parser = new FileIniDataParser();
            IniData data;

            try
            {
                data = parser.LoadFile(args[0]);

                //Iterate through all the sections
                foreach (SectionData section in data.Sections)
                {
                    if (section.SectionName.StartsWith("NewFeedItem"))
                    {
                        // Do something interesting here.
                        // These three lines are not very interesting.
                        Console.WriteLine(section.SectionName);
                        Console.WriteLine("\t" + section.Keys["ItemTitle"]);
                        Console.WriteLine("\t" + section.Keys["PlainTextDescription"]);
                    }
                }
            }
            catch (Exception)
            {
                System.Console.WriteLine("Error: Invalid INI file or path.");
                System.Environment.Exit((int)ExitCode.InvalidIniFile);
            }
        }
    }
}

virla wrote:3] How channel hook will inform or notify to my application written in c# regarding new feed available on subscribed channel.

That's something only you can answer.
What is your application? A GUI-based EXE? A console-based EXE? A web application?

A Channel hook can call virtually any other process: SOAP, REST, COM, etc.
How is your application callable?

What are you trying to accomplish?


Return to “Awasu - Extensions”

Who is online

Users browsing this forum: No registered users and 3 guests