i am posting comments on my blog it works fine but there is one problem that i cannot post anonymous comments using XML-RPC by alexjamesbrown
instead of comment author there is name of admin
here is my code
var wrapper = new WordPressWrapper(textblogUrltemp + "/xmlrpc.php", adminunUser, adminPass);
var post = new Post();
post.title = toPost.VideoTitle;
post.dateCreated = Convert.ToDateTime(toPost.PostingDateTime);
post.description = toPost.VideoCode;
post.postid = wrapper.NewPost(post, true);
var comment = new Comment();
var wrap =new WordPressWrapper(textblogUrltemp + "/xmlrpc.php", adminunUser, adminPass);
comment.author = videoComments.userName;
comment.author_email = videoComments.email;
comment.content = videoComments.Comment;
wrap.NewComment(post.postid, comment);
I resolved it
var wrap =new WordPressWrapper(textblogUrltemp + "/xmlrpc.php", "", "");
also you need to modify the class-wp-xmlrpc-server.php file and in newComment function allow the anonymous comments
I bumped into this working for WP Remote Control. Very bad idea to unlock anonymous posting through XMLRPC. You can get flooded by Spam as anyone can do it.
The secret is to post the comment and edit it. Two requests but you're safe. There's a single method that does it in my class. Regards.
BTW: My class is PHP. I have it written in C++ too but it's too dependent to my C++ library to publish.
Related
I'm having trouble creating a new ContentVersion - Right now I have created a new entry with this code.
var newItem = await client.DeviceAppManagement.MobileApps.Request().AddAsync(new Win32LobApp {});
But I can't find the method to create a new ContentVersion. I know the URL, but not the method to call.
The URL to call is this
POST: https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/{0}/microsoft.graph.win32LobApp/contentVersions
So far I have tried to clone the github project (https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet) to see how it works, but without luck. And right now, I just don't know where to look.
Any help would be appreciated
Okay, I solved it by doing it like this
ManagedMobileLobAppRequestBuilder builder = new ManagedMobileLobAppRequestBuilder($"{client.BaseUrl}/deviceAppManagement/mobileApps/{newItem.Id}/{newItem.ODataType.Substring(1)}", client);
var result = await builder.ContentVersions.Request().AddAsync(new MobileAppContent());
Not sure if this is the correct way of doing it, but it works!
An alternative solution with a little less string concatenation:
var lobType = createAppResult.ODataType.Substring(1);
var baseUrl = client.DeviceAppManagement.MobileApps[appId].AppendSegmentToRequestUrl(lobType)
var lobRequestBuilder = new ManagedMobileLobAppRequestBuilder(baseUrl, client);
I am using REST API C# to develop a tool. I would like to get project info based on owner name.
Does anyone have some sample code on how it should works?
Below is my code but it's not working.
Request ProjRequest = new Request("Projects");
ProjRequest.Workspace = "/workspace/xxx";
ProjRequest.Fetch = new List<string>()
{"Name"};
ProjRequest.Query = new Query("Owner.UserName", Query.Operator.Equals, "user name");
ProjResult result = restApi.Query(ProjRequest);
That looks pretty close. I think you just need to change the type to be singular:
Request ProjRequest = new Request("Project");
If that is still not working, inspect the Errors collection on the response and see what's wrong...
Im trying to move a file from one folder to another using the Google Drive API v3. I found documentation how to this here. I used the .NET sample code from the documentation page and created a method that looks like this:
public ActionResult MoveFile(string fileToMove, string destination)
{
DriveService service = new DriveService(new BaseClientService.Initializer
{
HttpClientInitializer = <USER CREDENTIAL>,
ApplicationName = "APPNAME"
});
var searchFiles = service.Files.List();
searchFiles.Corpus = FilesResource.ListRequest.CorpusEnum.User;
searchFiles.Q = "name = '" + fileToMove + "'";
searchFiles.Fields = "files(*)";
string fileToMoveId = searchFiles.Execute().Files[0].Id;
searchFiles.Q = "name = '" + destination + "'";
string destinationId = searchFiles.Execute().Files[0].Id;
//Code used from documentation
// Retrieve the existing parents to remove
var getRequest = service.Files.Get(fileToMoveId);
getRequest.Fields = "parents";
var file = getRequest.Execute();
var previousParents = String.Join(",", file.Parents);
// Move the file to the new folder
var updateRequest = service.Files.Update(file, fileToMoveId);
updateRequest.Fields = "id, parents";
updateRequest.AddParents = destinationId;
updateRequest.RemoveParents = previousParents;
file = updateRequest.Execute();
return RedirectToAction("Files", new {folderId = destinationId});
}
When I execute this code I get the following error:
The parents field is not directly writable in update requests. Use the
addParents and removeParents parameters instead.
The error doesn't really makes sense to me because this code sample came from the documentation page itself. I can't figure out what other paramters they mean. What addParents and removeParents parameters do they mean? Are updateRequest.AddParents and updateRequest.RemoveParents not the right parameters?
Ok here is the problem.
var updateRequest = service.Files.Update(file, fileToMoveId);
The method is requiring that you send a body of a file to be updated. This normally makes sense as any changes you want to make you can add to the body.
Now the problem you are having is that you got your file from a file.get. Which is totally normal. This is how you should be doing it. THe problem is there are some fields in that file that you cant update. So by sending the full file the API is rejecting your update. If you check Files: update under Request body you will see which fiends are updateable.
Issue:
Now this is either a problem with the client library or the API I am going to have to track down a few people at Google to see which is the case.
Fix:
I did some testing and sending an empty file object as the body works just fine. The file is moved.
var updateRequest = service.Files.Update(new Google.Apis.Drive.v3.Data.File(), fileToMove.Id);
updateRequest.AddParents = directoryToMove.Id;
updateRequest.RemoveParents = fileToMove.Parents[0];
var movedFile = updateRequest.Execute();
This method works well when working in your own drive, but not in a team drive where a file (folder) can only have 1 parent strictly. I do not have the solution in a team drive
I'm trying to use the InitiateFileTransferToGuest method to send a file to a VM. Unfortunately, I'm getting stuck. Here's the related code where VClient is the VimClient with an already successfull connection:
GuestOperationsManager VMOpsManager = new GuestOperationsManager(VClient, VClient.ServiceContent.GuestOperationsManager);
GuestFileManager VMFileManager = new GuestFileManager(VClient, VClient.ServiceContent.FileManager);
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, VClient.ServiceContent.AuthorizationManager);
NamePasswordAuthentication Auth = new NamePasswordAuthentication()
{
Username = "username",
Password = "password",
InteractiveSession = false
};
VMAuthManager.ValidateCredentialsInGuest(CurrentVM.MoRef, Auth);
System.IO.FileInfo FileToTransfer = new System.IO.FileInfo("C:\\userlist.txt");
GuestFileAttributes GFA = new GuestFileAttributes()
{
AccessTime = FileToTransfer.LastAccessTimeUtc,
ModificationTime = FileToTransfer.LastWriteTimeUtc
};
string TransferOutput = VMFileManager.InitiateFileTransferToGuest(CurrentVM.MoRef, Auth, "C:\\userlist.txt", GFA, FileToTransfer.Length, false);
First error shows up when getting to the ValidateCredentialsInGuest method. I get this message:
An unhandled exception of type 'VMware.Vim.VimException' occurred in VMware.Vim.dll Additional information: The request refers to an unexpected or unknown type.
If I remove that validation, I get the same error when trying to run InitiateFileTransferToGuest. I've been browsing the API documentation, and threads in VMware forums and a lot of places to be honest. The only pieces of code I've seen posted where it works were in Java and Perl, but the API implementation is a little different than C#. Any idea where to look?
Thank you!
I made it work after testing and making up stuff. I guessed the MoRef for both AuthManager and FileManager doing the following:
ManagedObjectReference MoRefFileManager = new ManagedObjectReference("guestOperationsFileManager");
GuestFileManager VMFileManager = new GuestFileManager(VClient, MoRefFileManager);
ManagedObjectReference MoRefAuthManager = new ManagedObjectReference("guestOperationsAuthManager");
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, MoRefAuthManager);
Now it's working, and I have no idea how.
I have been trying to create an application to go through our database at a set interval and update/add any new items to 3DCarts database. Their code example uses soap in an xml file to send 1 request per call. So I need to to be able to generate the xml I need with the items information on the fly before sending it. I have done hardly anything with XML files like this and cannot figure out how to create the chunk of code I need and send it. One method that has been suggested is create a file but still executing has been a problem and would be very inefficient for a large number of items. Here is what I have so far
sqlStatement = "SELECT * FROM products WHERE name = '" + Convert.ToString(reader.GetValue(0)) + "'";
ServiceReferenceCart.cartAPIAdvancedSoapClient bcsClient = new ServiceReferenceCart.cartAPIAdvancedSoapClient();
ServiceReferenceCart.runQueryResponse bcsResponse = new ServiceReferenceCart.runQueryResponse();
bcsClient.runQuery(storeUrl, userKey, sqlStatement, callBackURL);
string result = Convert.ToString(bcsResponse);
listBox1.Items.Add(result);
EDIT: Changed from sample code block to current code block as I got a service reference setup finally. They provide no details though for using the functions in the reference. With this bcsResponse is just a blank, when I try adding .Body I have the same result but when I add .runQuery to the .Body I get a "Object reference not set to an instance of an object." error. As I have said I have not messed with service references before.
I hope I have explained well enough I just really have not worked with this kind of stuff before and it has become extremely frustrating.
Thank you in advance for any assistance.
I actually ended up figuring this out after playing around with it. Here is what I did to get the reference to work. This may have been easy for anyone who have used the references before but I have not and have decided to post this in case anyone else has this problem. The SQL can be SELECT, ADD, UPDATE and DELETE statements this was to see if the sku was listed before updating/adding.
//Will be using these multiple times so a variable makes more sense
// DO NOT include http:// in the url, also id is not shown in their
//database layout pdf they will give but it is the sku/product number
string sqlStatement = "SELECT id FROM products WHERE id = '" + Convert.ToString(reader.GetValue(0)) + "')))";
string userKey = "YourKeyHere";
string storeUrl = "YourStoresURLHere";
// Setting up instances from the 3DCart API
cartAPIAdvancedSoapClient bcsClient = new cartAPIAdvancedSoapClient();
runQueryRequest bcsRequest = new runQueryRequest();
runQueryResponse bcsResponse = new runQueryResponse();
runQueryResponseBody bcsRespBod = new runQueryResponseBody();
runQueryRequestBody bcsReqBod = new runQueryRequestBody();
//assigning required variables to the requests body
bcsReqBod.storeUrl = storeUrl;
bcsReqBod.sqlStatement = sqlStatement;
bcsReqBod.userKey = userKey;
//assigning the body to the request
bcsRequest.Body = bcsReqBod;
//Setting the response body to be the result
bcsRespBod.runQueryResult = bcsClient.runQuery(bcsReqBod.storeUrl, bcsReqBod.userKey, bcsReqBod.sqlStatement, bcsReqBod.callBackURL );
bcsResponse.Body = bcsRespBod;
//adding the result to a string
string result = bcsResponse.Body.runQueryResult.Value;
//displaying the string, this for me was more of a test
listBox1.Items.Add(result);
You will also need to activate the Advanced API on your shop as you may notice there is no actual option as the pdf's say, you need to go to their store and purchase(its free) and wait for them to activate it. This took about 2 hrs for us.