Portal IDs are the Object ID of the portal object. You can get the Object ID of a portal by hooking the UpdatePacket and looping through the New Objects array. The ObjectType property of each new object will indicate whether or not it is a portal.
Player IDs work in a similar way. Just check if the ObjectType matches up with a value in the Classes enum.