hi, i am trying to get into dynamic plugins. That is my first time experimenting with c# and the code editor. The code below is taken more or less from the web and it is kind of working but there are some points i can not figure out myself.
It is supposed to post to a facebook wall. This is working, but…
-
I am able to read the facebook responses from tty only for now. I have tried to output them via FOutput pin but the code editor keeps telling me: “can not implicitly convert type char to string”. The used variable is declared as string. how am i supposed to convert it to the right data type?
The code is running fine in sharpdevelop and the responses show up in the console “Console.Write(Response…)” -
I have tried to feed the post text from an Input pin but it does not work for me, so for now i have to “hardcode” the text (see “Test123”). I have replaced the “Test123” with the FinputText variable but then “VVVV.Hosting.Pins.Input.StringInputPin: InputText” is posted. is there something obvious i am doing wrong?
for example works ok
I hope someone can give me some hints.
- region usings
using System;
using System.ComponentModel.Composition;
using VVVV.PluginInterfaces.V1;
using VVVV.PluginInterfaces.V2;
using VVVV.Utils.VColor;
using VVVV.Utils.VMath;
using System.Net;
using System.Text;
using VVVV.Core.Logging;
- endregion usings
namespace VVVV.Nodes
{
#region PluginInfo
[PluginInfo(Name = "Testing", Category = "String", Help = "Basic template with one string in/out", Tags = "")](PluginInfo(Name = "Testing", Category = "String", Help = "Basic template with one string in/out", Tags = ""))
#endregion PluginInfo
public class StringTestingNode : IPluginEvaluate
{
#region fields & pins
[Input("Bang", IsBang=true, IsSingle=true)](Input("Bang", IsBang=true, IsSingle=true))
ISpread<bool> FInput;
[Input("InputText")](Input("InputText"))
ISpread<string> FInputText;
[Output("Output")](Output("Output"))
ISpread<string> FOutput;
[Import()](Import())
ILogger FLogger;
#endregion fields & pins
//called when data for any output pin is requested
public void Evaluate(int SpreadMax)
{
byte[]() MessageToPost = null;
byte[]() ResponseFromServer = null;
string AccessToken = "XXXXXXXXXXXXXXXX";
string GraphURL = "https://graph.facebook.com/me/feed";
if (FInput[0](0))
try {
MessageToPost = Encoding.UTF8.GetBytes("message=" + "Test123"
+ "&access_token=" + AccessToken);
System.Net.WebClient myWebClient = new System.Net.WebClient();
ResponseFromServer = myWebClient.UploadData(GraphURL, MessageToPost);
string ResponseFromServerAsString = (System.Text.Encoding.UTF8.GetString(ResponseFromServer));
FLogger.Log(LogType.Debug, ResponseFromServerAsString);
FOutput.SliceCount = SpreadMax;
// for (int i = 0; i < SpreadMax; i++)
// does not work-> FOutput[i](i) = ResponseFromServerAsString[i](i);
} catch (Exception ex) {FLogger.Log(LogType.Debug, ex.Message);}
}
}
}