Hi.
If you are going to use an optocoupler then there is a nice explanation under answer #4 at this link:
Still your code has to take care of disappearing input signal during zero crossing and in that case the part with two antiparallel LED's would provide you higher percentage of ON time. It would be also a good precaution to have a board slotted under the optocoupler between high/low voltage side.
Edit: If possible stay far below the maximum rated input current in order to be able to handle at least 1.2kV voltige spikes in the mains lines. Otherwise the thing may be good until the next thunderstorm. If the circuit is "mission critical" then it would be perhaps even better to also include a varistor across the input line.