HTTP 302 - Not found parameter GSessionID - Google Calendar - delphi

I need help .
I want to create events on google calendar with a desktop application , when the parameters sent
url = 'https://www.google.com/calendar/feeds/emaill%40gmail.com/private/full';
and then add xml where this event to create
createXML := '<?xml version=''1.0'' encoding=''UTF-8''?>'#13#10 +
'<entry xmlns=''http://www.w3.org/2005/Atom'''#13#10 +
'xmlns:gd=''http://schemas.google.com/g/2005''>'#13#10 +
'<category scheme=''http://schemas.google.com/g/2005#kind'''#13#10 +
'term=''http://schemas.google.com/g/2005#event''></category>'#13#10 +
'<title type=''text''>' + title + '</title>'#13#10 +
'<content type=''text''>' + content + '</content>'#13#10 +
'<gd:transparency'#13#10 +
'value=''http://schemas.google.com/g/2005#event.opaque''>'#13#10 +
'</gd:transparency>'#13#10 +
'<gd:eventStatus'#13#10 +
'value=''http://schemas.google.com/g/2005#event.confirmed''>'#13#10 +
'</gd:eventStatus>'#13#10 +
'<gd:where valueString=''' + location + '''></gd:where>'#13#10 +
'<gd:when startTime=''' + EventStartTime + ''''#13#10 +
'endTime=''' + EventEndTime + '''></gd:when>'#13#10 +
'</entry>';
When I do the POST process the next header appears
HTTP/1.0 302 Moved Temporarily
Expires: Wed, 30 April 2014 17:37:17 GMT
Date: Wed, 30 April 2014 17:37:17 GMT
Set- Cookie: T=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
Expires = Tue, 13 -May- 2014 10:32:28 GMT;
SecureLocation : https://www.google.com:443/calendar/feeds/default/private/full?t=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content- Type: text / html ; charset = UTF -8
Cache- Control: private , max -age = 0
X -Content -Type -Options : nosniff
X -Frame -Options : SAMEORIGIN
X -XSS -Protection : 1; mode = block
Server : GSE
Alternate -Protocol : 443: quic
In the manual, Google listed me I need a variable called " GSessionID " but does not appear to me,
I would please help me with this problem .
I have two projects with authentication: ClientLogin and OAuth 2.0
as I get to get this parameter?
Thanks a lot.
Us Google Translator

It has to work to retrieve the newly loaded gsessionID condition Realize post procedure twice, the second in the exception
try
idHTTP2.Post(URL,XML);
except on E: EIdHTTPProtocolException do
idHTTP2.Post(URL,XML);
end;
Thanks for your time.

Related

HTTPS Post Request with ESP8266

I'm trying to send an HTTPS POST request with a ESP8266. I can make the request just fine with python and cURL just when I try it with the ESP it doesn't work. A segment of my code is below
const char *host = "api.pushbullet.com";
const int httpsPort = 443;
const char fingerprint[] PROGMEM = "4C 70 C5 AE F3 30 E8 29 D1 9C 18 C6 2F 08 D0 6A A9 AA 19 0F";
Link = "/post";
httpsClient.print(String("POST ") + Link + " HTTP/1.1\r\n" +
"Host: " + host + "/v2/pushes" + "\r\n" +
"Access-Token: *************"+ "\r\n" +
"Content-Type: application/json"+ "\r\n" +
"Content-Length: 20"+ "\r\n" +
"body: Hello World" + "\r\n\r\n");
Serial.println("request sent");
The request I'm trying to make is below. This works just fine in python
import requests
headers = {
'Access-Token': '***********',
'Content-Type': 'application/json',
}
data = '{"body":"Hello World","title":"Hi","type":"note"}'
response = requests.post('https://api.pushbullet.com/v2/pushes', headers=headers, data=data)
And in cURL:
curl --header 'Access-Token: **********' --header 'Content-Type: application/json' --data-binary '{"body":"Hello World","title":"Hi","type":"note"}' --request POST https://api.pushbullet.com/v2/pushes
When I make the request with the Arduino code it returns "Error 411 (Length Required)!!".
This is probably due to some stupid mistake I've made but if anyone could help me fix my Arduino code I'd be very grateful. Thanks
There are a few mistakes in your code.
your http POST format are incorrect in a)host name, b)uri, and c)header/body separation;
your http body is not a valid json object.
Here is an example on sending the http (without using String):
const char *host = "api.pushbullet.com";
const char *uri = "/post/v2/pushes/";
const char *body ="{\"body\": \"Hello World\"}"; // a valid jsonObject
char postStr[40];
sprintf(postStr, "POST %s HTTP/1.1", uri); // put together the string for HTTP POST
httpsClient.println(postStr);
httpsClient.print("Host: "); httpsClient.println(host);
httpsClient.println("Access-Token: *************");
httpsClient.println("Content-Type: application/json");
httpsClient.print("Content-Length: "); httpsClient.println(strlen(body));
httpsClient.println(); // extra `\r\n` to separate the http header and http body
httpsClient.println(body);
General advice: when you use cURL always use --verbose to see the full HTTP exchange.
In your case it should be
httpsClient.print(String("POST ") + "/v2/pushes" + Link + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Access-Token: *************"+ "\r\n" +
"Content-Type: application/json"+ "\r\n" +
"Content-Length: 20"+ "\r\n" +
"body: Hello World" + "\r\n\r\n");
Note how
the path is "/v2/pushes/" plus identifier ("Link" in your case?)
Host is just "api.pushbullet.com"
Side notes:
make sure you send correct values for Content-Length
consider using HTTPClient if you are not confident with low-level HTTP programming

Collecting card details within the app on Telr Payment gateway

I am integrating "Telr" payment gateway on my current app.I have read all docs part. My app will be collecting the card details (rather than using the hosted payment pages).This is the request i am making.If anybody has some demo or integrated Telr payment gateway, please feel free to reply.
let paramString: String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<mobile>" +
"<store>\(12345)</store>" + "<key>somekey</key>" +
"<device>" +
"<type>\("iPhone6")</type>" +
"<id>\(deviceId)</id>" +
"<agent></agent>" +
"<accept></accept>" +
"</device>" +
"<app>" +
"<name>Telr_Payment_Demo</name>" +
"<version>1.0</version>" +
"<user>xyz.Demo</user>" +
"<id>1234567</id>" +
"</app>" +
"<tran>" +
"<test>12</test>" +
"<type>paypage</type>" +
"<class>moto</class>" +
"<cartid>syste1075</cartid>" +
"<description>this is demo on telr</description>" +
"<currency>AED</currency>" +
"<amount>\(9.80)</amount>" +
"<ref>\("000000000001")</ref>" +
"</tran>" +
"<card>" +
"<number>\("5555555555554444")</number>" +
"<expiry>" +
"<month>\(02)</month>" +
"<year>\(2018)</year>" +
"</expiry>" +
"<cvv>\(123)</cvv>" +
"</card>" +
"<billing>" +
"<name>" +
"<title>\("fsfsfs")</title>" +
"<first>\("First")</first>" +
"<last>\("last")</last>" +
"</name>\n" +
"<address>" +
"<line1>\("Kathmandu bazar")</line1>" +
"<line2>\("address 6")</line2>" +
"<line3>\("Near gausala")</line3>" +
"<city>\("kathmandu")</city>" +
"<region>\("Bagmati")</region>" +
"<country>\("Nepal")</country>" +
"<zip>\("977")</zip>" +
"</address>" +
"<email>\("s*********#gmail.com")</email>" +
"</billing>" +
"</mobile>"
I am getting following response from server
<mobile>
<webview>
<start>https://secure.innovatepayments.com/gateway/webview_start.html? code=f1caa6ce6c23595b71dc00369</start>
<close>https://secure.innovatepayments.com/gateway/webview_close.html</close>
<abort>https://secure.innovatepayments.com/gateway/webview_abort.html</abort>
<code>f1caa6ce6c23595b71dc00369</code>
</webview>
<trace>40008/1683846/595b7168dc</trace>
</mobile>
The first url will redirect to hosted payment pages card details view.I do not know what should i do with that response.This is the payment integration guidelines for developer.
From the docs you linked to say:
When a webview response is received, the App will need to direct the
customer to the URL given as the start address. The App should monitor
the progress of the webview, and once it reaches the URL provided as
the close address, it should close the web display and continue with
the transaction process.
To complete the transaction, the App must now make a second request to
the gateway. This request includes will trigger the final
authorisation stage of the transaction, and return the authorisation
response. The request must be sent to:
https://secure.innovatepayments.com/gateway/mobile_complete.xml
...
so I would start with that and see what happens

CPCL command not working with Zebra printer iMZ320 but work with MZ 320

The CPCL command which is use to communicate with Zebra Printer MZ 320 is
not working with iMZ 320 model.
Following is the CPCL command used:
Works with MZ 320 but not with iMZ 320
var testPrint = '! 0 200 200 210 1 \r\n' + 'TEXT 4 0 200 100 TESTPRINT' + ' \r\n' + 'FORM \r\n' + 'PRINT\r\n';
Works for both MZ 320 and iMZ 320
var barcodeTxt = "123456789";
var barcode = '! 0 200 200 210 1 \r\n' + 'BARCODE 128 1 1 50 150 10 ' + barcodeTxt + ' \r\n' + 'TEXT 7 0 210 60 ' + barcodeTxt + ' \r\n' + 'FORM \r\n' + 'PRINT\r\n';
It will be helpful if someone provided the solution.
Thanks in Advance.
try
var testPrint = '\r\n! 0 200 200 210 1 \r\n' + 'TEXT 4 0 200 100 TESTPRINT' + ' \r\n' + 'FORM \r\n' + 'PRINT\r\n';
Make sure that the iMZ320 is in line mode as it may come configured differently due to the different architecture and application. Also you may have to calibrate the printer for the Mark media you use (see the printer manual).

How to avoid Restart Bluetooth Printer after print?

I have developed windows mobile 6.1 application which search nearby Bluetooth devices and send files.Also I did print functionality to print document on Bluetooth printer.
First time print functionality is working perfectly fine but when I print the document again, then I need to restart the printer and then after it will print.
Is there any solution to avoid restart printer??
Below is my print code from reference of https://32feet.codeplex.com/discussions/355451
private void btPrint_Click(object sender, EventArgs e)
{
// Activate BT
BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
System.Threading.Thread.Sleep(1000);
// Connect
BluetoothAddress btAddress;
btAddress = BluetoothAddress.Parse("0022583165F7");
BluetoothClient btClient = new BluetoothClient();
try
{
btClient.Connect(new BluetoothEndPoint(btAddress, BluetoothService.SerialPort));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
// Send data
string CPCLStr1 =
"! 0 200 200 210 1" + Environment.NewLine +
"ML 25" + Environment.NewLine +
"TEXT 7 0 10 20" + Environment.NewLine +
"Just" + Environment.NewLine +
"Testing" + Environment.NewLine +
"ENDML" + Environment.NewLine +
"FORM" + Environment.NewLine +
"PRINT" + Environment.NewLine;
// Convert CPCL String to byte array
byte[] CPCLbytes1 = ASCIIEncoding.ASCII.GetBytes(CPCLStr1);
NetworkStream ns = btClient.GetStream();
ns.Write(CPCLbytes1, 0, CPCLbytes1.Length);
btClient.Close();
}
Although you close the client stream, the printer seems to wait some time before it resets it's session.
Try to send a <EOF> or <EOT> byte at the end.
Acording to CPCL reference guide there is no simple reset command as with ESC/p for example ({esc}#).
Doing a device reset after every print seems an overkill.
EDIT: SDK sample for sendFile:
Byte[] cpclLabel = Encoding.Default.GetBytes("! 0 200 200 406 1\r\n" + "ON-FEED IGNORE\r\n"
+ "BOX 20 20 380 380 8\r\n"
+ "T 0 6 137 177 TEST\r\n"
+ "PRINT\r\n");
The above runs fine on my RW420 without the need to reset between prints.

Google Analytics & Blackberry UserAgent

I'm using this code to get the blackberry info on google analytics
private static String getUserAgent()
{
String userAgent = "Blackberry" + DeviceInfo.getDeviceName() + "/" +
getOsVersion() + " Profile/" + System.getProperty(
"microedition.profiles" ) + " Configuration/" + System.getProperty(
"microedition.configuration" ) + " VendorID/" +
Branding.getVendorId();
return userAgent;
}
And then using it here :
conn.setRequestProperty("User-Agent", userAgent);
The problem is that it doesn't recognize the terminal like a mobile phone , but it takes difference in browser .
Browser:
Navegador Visitas % Visitas
1. Blackberry8900 36 100,00%
Any idea if google analytics have some params to know that is a mobile phone ? or if i'm using a badformated useraggent.
Thanks for your answers.

Resources