I want to get notifications when a new feed has landed on a designated page (by page id). After what I understand, the Realtime-update og Graph API should be able to do this trick according to https://developers.facebook.com/docs/graph-api/real-time-updates/v2.4.
So I want to add a new subscription, which I try to do with the following code:
dynamic result = client.Post(urlPath, new
{
#object = "page",
callback_url = callbackUrl,
fields = "feed",
verify_token = "654321",
access_token = accessToken
});
return result;
But when I try to run this, I'm getting the following error code:
(OAuthException - #2200) (#2200) callback verification failed: Received HTTP code 502 from proxy after CONNECT"
What do I miss?
The callback url is https://127.0.0.1:8989/ and I have a TcpListener running on the port, which does not seem to get any response/request incoming...
The application is a C# console application, so no fancy asp.net stuff or something. I'm using the Facebook .net SDK.
Should I FacebookClient.VerifyPostSubscription() or anything else that I missed out?? Maybe the SDK wraps a handle?
So the answer I'm looking for is:
- How do I create/add a subscription for feeds of a facebook page, using the .net SDK on a windows console project??
UPDATE:
I changed the loopback with a domain name, that I the NAT to my target machine, and now I actually get some encrypted data on my TcpListener!
So, the question now is, how do I respond correctly to this received respons, only by using a Tcp Client??
How you have to respond is exactly outlined in the docs you linked:
https://developers.facebook.com/docs/graph-api/real-time-updates/v2.4#setupget
It's not really clear what you mean with "TCP listener". You need to have some logic why can send HTTP responses to the Facebook servers, otherwise your service will be disregarded after some time, meaning no updates will be send.
Typically, this is implemented as a script/application in a web/application server.
Please note: The "C# SDK" is a third-party SDK and not officially supported by FB.
Related
I'm currently writing my first program using the C# Kubernetes API. I want to send REST requests to a service that is running within a pod in my cluster. Does the library have any functionality to do that? I already tried to get the IP of the pod and then send the request manually, but I can't find a way to get this information.
Ok I think I got it now, thanks to the Input of David Maze. I will accept this answer as soon as I've gotten around to test it.
#DavidMaze Feel free to post this answer yourself, then I will accept that one instead.
config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
client = new Kubernetes(config);
V1ServiceList services = client.ListNamespacedService("MyNamespace");
foreach(var s in services.Items)
{
if (s.Metadata.Name.Contains("MyService"))
{
standardHTTPRequest(s.Spec.ClusterIP);
}
}
I've built a web api that is called via an application (iOS/Android) through HTTP requests. I'm trying to implement a GET request that returns different data based on the device, OS, application version, .. etc. I've been using UserAgent with IOS devices and it's working just fine, it goes like that:
var uaParser = Parser.GetDefault();
var clientInfo = uaParser.Parse(Request.Headers.UserAgent.ToString());
Also if I opened the request via browser it also returns the data. Example of the response is: UserAgent: Windows 10 Other Chrome 63.0.3239
The problem is in the Android devices, it doesn't send any data about neither the device nor the OS, and I don't want to hard code the details in the android apps, I believe they are sent somewhere as Crashlytics can show these details for both iOS and Android.
Is there is any possible solution to get this data from the requests itself?
If you really wana do that then you could programically get android device name and its version and send it to your server as a parameter in http request...
To get Device Name
String devName = android.os.Build.MODEL;
To get Version code
String androidOS = Build.VERSION.RELEASE;
Then You Could Easily Send Them To Your Server As A Parameter In Your Request And Store Them To Database etc....Hope This Helps ! Cheers !
I am attempting to follow a Windows Azure tutorial to send a message to a topic on Microsoft's Azure service bus. I have created the namespace and the topic. I then set up ACS and grabbed my connection string. My connection string allows Manage, Listen, Send. When I execute my code, the Send(message) just hangs. It never times-out nor does it continue. The CPU is not maxed and I can break out of the code and close the program. No message arrives in Azure. When I watch my network traffic in fiddler, it looks to me like it is never finishing the authentication negotiations. I see a post to my namespace .servicebus.windows.net that returns a 201 then a post and a get at an IP address that belongs to Azure service bus with a /$servicebus/webstring/{guid}. Neither of these web request ever get a response back from the server. Here is my code. It stops running on client.Send(message);
static void Main(string[] args)
{
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;
string connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
var client = TopicClient.CreateFromConnectionString(connectionString, "clients");
Console.WriteLine(client.IsClosed);
var message = new BrokeredMessage("Test message.") {TimeToLive = TimeSpan.FromMinutes(15)};
client.Send(message);
Console.WriteLine("Done");
Console.ReadKey();
}
Any ideas on how to get this code to post a message to Azure service bus?
I'm also seeing this behavior when using this code and it appears to be linked to the ServiceBusEnvironment.SystemConnectivity.Mode you have set. If you comment that out it goes through. That mode isn't mentioned in the tutorial. The default the mode is Auto and it detects if it can send via TCP first.
With that said, I'd like to suggest you use the following code instead:
string connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
MessagingFactory factory = MessagingFactory.CreateFromConnectionString(connectionString);
MessageSender testQueue = factory.CreateMessageSender("TestTopic");
BrokeredMessage message = new BrokeredMessage("Test message ");
testQueue.Send(message);
One of the benefits of using the MessageSender instead of the TopicClient or QueueClient directly is that your code doesn't care if the destination is a Topic or a Queue. If you later needed to change from one to another your code here wouldn't have to change. Likewise, using a MessageReceiver on the consuming code is better as well.
I dont see that issue, I can post the message on a topic with same code and receive it via a subscription as well. The SAS key I use is generated on Topic itself. My the issue you had was temporary issue?
It appears to be our corporate firewall. It is actively refusing connections on unknown ports (9354) instead of passively. This seems to keep the Microsoft library for Azure from auto-detecting the connection and switching to https. It appears that with an active refusal of the connection at 9354 an exception get thrown in the library instead of trying http. Likewise, if I set the mode to just Http, it hangs, but when I am outside the corporate firewall it does not hang. It would be nice if this library worked with an active refusal on port 9354.
From a Winforms application using the same connection code, RavenDB works fine. I'm able to store and retrieve documents with abandon.
When I try to do the same thing in a Nancy application the result is completely unexpected.
Nancy is listening on port 12345, and RavenDB is running in Embedded mode with UseEmbeddedHttpServer enabled and listening on port 8080.
The very first request to http://localhost:12345/ gets a web page response as requested. Any subsequent request to http://localhost:12345/ is redirected to /raven/studio.html. If the first request I make is to /widgets Nancy returns a JSON list of widgets as expected, but any subsequent request returns:
Could not figure out what to do
Your request didn't match anything that Raven knows to do, sorry...
It seems like RavenDB is hijacking the port Nancy is listening on. Any ideas what would cause this behaviour?
When hosted by IIS, the port for RavenDB needs to be set explicitly.
The default value is coming from IIS config, which is why it isn't an issue when running embedded mode from a Winforms application.
(db as EmbeddableDocumentStore).Configuration.Port = 8080;
There's no good reason I can think of that it would do that.
Perhaps you should specify an explicit Raven/Port setting. See these docs.
Or you can do it programatically:
var store = new EmbeddableDocumentStore {UseEmbeddedHttpServer = true};
store.Configuration.Port = 8080;
i have developed a server application with c# and a client application with flash action script 3.0. Flash socket asking for a policy file when called from a browser with a message
<policy-file-request/>
everything is normal so far. My server is waiting for this message and sending to client a policy file string which is like this:
public const String POLICY_FILE = "<?xml version=\"1.0\"?>\n" +
"<!DOCTYPE cross-domain-policy SYSTEM \"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">\n" +
"<cross-domain-policy>" +
"<allow-access-from domain=\"*\" to-ports=\"*\" />" +
"</cross-domain-policy>\u0000";
this string is being sent this way:
if (message.Contains("policy-file-request"))
{
client.Send(Encoding.ASCII.GetBytes(Statics.POLICY_FILE));
return;
}
I'm pretty sure that this was working but i really don't know what happened and started not working. When flash client receives this message from server, connection was succesfull and everything was going how it had to go. But now the flash client waits 20 seconds (timeout of flash socket) and throws security exception
[SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048"]
I'm stuck and can't move forward. I'm listening to port 963, server machine fully qualified name is "mypc.domain.local" which can be accessible across my network. there is also an IIS running on this machine and the flash application is hosted here.
http://mypc.domain.local:90/page.html
this is the way, i call my flash application and
mypc.domain.local:963
is the address of server running. i am also working on this machine. i tried calling the page http://localhost:90/page.html or http://127.0.0.1:90/page.html and also tried the connection to server as localhost:963 or 127.0.0.1:963. same result on every combination.
What is wrong here? what could have been changed causing my working code broke down?
Thanks.
It's hard to tell without more code, but based on what you've shown, it appears that when that request comes in, you respond with the contents of the policy file, which isn't an actual valid HTTP response. My guess for the 20 second timeout would be that it's still waiting for the HTTP headers.
If possible, try to use the HTTP classes already in the BCL instead of doing http 'manually', but if you have to do the socket stuff yourself, then use something like Fiddler during debugging since it's great for identifying violations of the HTTP protocol.